You do not ask for a thread pool, but instead, you will receive each background thread for notification of completion.
But do not do this plumbing yourself, use the new TPL and the Task class:
var tasks = new Task[10]; for (int i=0;i<10;i++) { tasks[i] = Task.Factory.StartNew( Go ); } Task.WaitAll(tasks); Console.WriteLine("All done"); void Go() { Console.WriteLine("Hello"); }
EDIT: I would question why you want exactly 10 threads doing the work. The default task scheduler already optimizes the number of detected CPU cores. But if you need, there is an implementation of TaskScheduler that limits the degree of concurrency to a fixed number here: http://msdn.microsoft.com/en-us/library/ee789351.aspx
source share