in reply to Re^3: How to create thread pool of ithreads
in thread How to create thread pool of ithreads
Is the AnonymousMonk above also you?
The threads will automatically go into a wait state when there is nothing in the queue. And as soon as you add something new to the queue, one of them will wake up to deal with it. That's the beauty of the architecture.
Now, assuming you're the AnonyMonk from above, the way to deal with the situation of the queue growing when you have large volumes of work items available very quickly, is to slightly restructure the code above to start the threads first, and then feed the work items into the queue in batches, and sleeping between batches to give the workers time to deal with them. There are several arrangements for doing this and the best choice will depend upon other details of your application.
If you confirm that you are the anonymonk and this is the problem you are encountering, and you are prepared to divulge a little further information about your application, then I'll try to suggest an applicable arrangement.
|
|---|