Wait for tasks to get completed in threadpool.

Posted by Alien01 on Stack Overflow See other posts from Stack Overflow or by Alien01
Published on 2010-12-31T16:47:35Z Indexed on 2010/12/31 16:54 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

Hello

I have created a thread pool in C++ which stores all tasks in a queue. Thread pool start n number of threads which takes tasks from queue , process each task and then delete tasks from queue.

Now , I want to wait till all tasks get completed. Checking for empty queue for completion of tasks may not work as , task can be given to each thread and queue can be emptied but still the tasks can in processing mode.

I am not getting idea how to wait for all the tasks completion.This is a design problem. Any suggestions?

© Stack Overflow or respective owner

Related posts about c++

Related posts about Windows