title: How do I maintain a fixed collection of threads?
body: <p>Need suggestion for best approach for Multi-threading in c# 3.0 (No Parallel or Task)</p>
  
  <p>The situation is, I have a Queue with 500 items. At a particular time I can run only 10 threads (Max). Below is my code.</p>
  
  <pre><code>While (queue.Count &gt; 0)
  {
  Thread[] threads = new Thread[no_of_threads];
  for (int j = 0; j &lt; no_of_threads; j++)
   {
     threads[j] = new Thread(StartProcessing);//StartProcessing Dequeue one item each time //for a single thread
     threads[j].Start();
   }
  
   foreach (Thread objThread in threads)
   {
     objThread.Join();
   }
  }
  </code></pre>
  
  <p>Problem in this approach is, for an instance, if no_of_threads = 10 and out of them 9 threads are done with processing, and 1 thread is still working, I cannot come out of loop and delegate work to the free threads until all 10 threads are done.</p>
  
  <p>I need at all the time 10 threads should work till the queue count > 0.</p>