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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

threading 6
Thread 1
multi threading c# 10
force kill thread 6
Thread question 5
Explain this about threads 35
Threads - WaitForMultiObjects equivalent in C# 19
firing Multi-Threads sometimes misses 4

Back
Top