В то время как Вы не можете предотвратить использование тех наследованных участников к моему знанию, необходимо быть в состоянии скрыть их от IntelliSense с помощью EditorBrowsableAttribute:
Using System.ComponentModel;
[EditorBrowsable(EditorBrowsableState.Never)]
private string MyHiddenString = "Muahahahahahahahaha";
Редактирование: Просто видел это в комментариях для документации, которое делает его довольно бесполезным с этой целью:
существует видное примечание, которое указывает, что этот атрибут "не подавляет участников от класса в том же блоке". Это верно, но не завершено. На самом деле атрибут не подавляет участников от класса в том же решении.
What type of executor are you using?
ThreadPoolExecutor
.awaitTermination()
will do what you are asking about (it's effectively a bulk join operation).
As a total aside, ThreadPoolExecutor will allow you to set limits on the # of threads, etc... (might be better than going recursive like what you are doing if the thread count goes high, not sure).
PS - I doubt that executors will make your code run any faster, but they may make your code easier to read and maintain. Using a Thread pool will make things faster for this sort of algorithm, and the Executor makes it easy to work with thread pools.
Взгляните на Executors.newFixedThreadPool
, который позволяет вам создавать пул максимум из n потоков (избавляется от вашего «если») и ExecutorService. shutdown
и метод ExecutorsService.awaitTermination
.