Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows service which reads xml files from internet. I need to use threads such that 2 threads(of 12) run at a time, asynchronously. The 12 threads are to run in a sequential manner, 2 at a time. Please give me suggestion on how would i implement this..

Thanks.
Posted

What's the point of having 12 threads if only 2 are going to run at a time? Why not just create 2 threads, let them run and when one finishes create a another?

Anyway, this[^] should give you all the examples you need to start using threads.
 
Share this answer
 
wrote:
I need to use threads such that 2 threads(of 12) run at a time, asynchronously. The 12 threads are to run in a sequential manner, 2 at a time.


That is a terrible idea and never go for it. I'd suggest you to use a ThreadPool and forget about managing how many threads executes at a time. ThreadPool queues up the work requests and process them with optimum resources.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900