Thread Count

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a loop that on each interation will start a new thread and perform
some duties. However, I only want a certain number of threads running at the
same time. So lets say I know the loop will interate 15 times but I only want
3 threads to run at a time and once one is finished a new one starts until
all 15 threads end up running and the loop is complete.

Any good SIMPLE examples of such a thing out there?
 
Demetri said:
I have a loop that on each interation will start a new thread and perform
some duties. However, I only want a certain number of threads running at the
same time. So lets say I know the loop will interate 15 times but I only want
3 threads to run at a time and once one is finished a new one starts until
all 15 threads end up running and the loop is complete.

Any good SIMPLE examples of such a thing out there?

That sounds like an ideal kind of thing for a producer/consumer
relationship. See
http://www.pobox.com/~skeet/csharp/threads/deadlocks.shtml - from about
half the way down the page.
 
Back
Top