12 Sep
2010
12 Sep
'10
1:33 p.m.
On 09/12/2010 02:55 PM, Boris Schaeling wrote:
I want a worker thread to terminate if there is nothing to do. If there is something to do again and the worker thread has terminated I need to create a new one. Now I wonder if I can use boost::thread to detect whether the thread is running or not.
Boris
You might also want to think about a thread pool: A number of worker threads which do something like this: while(true) { wait_for_task; process_task; } Rather simple to implement and more effective (I think) than starting a new thread for each task. It also allows you to control the number of total worker threads easily. It is also simple to keep track of the number of working/waiting worker threads. Regards, Roland