Subj : Re: waiting on signals from multiple threads using pthreads To : comp.programming.threads From : David Schwartz Date : Mon Mar 14 2005 11:00 am wrote in message news:1110724540.309205.76350@z14g2000cwz.googlegroups.com... > In our application, we have three (possibly more) worker threads > performing some task and another thread which waits for completion of > all three tasks from the worker threads. All three worker threads are > NOT synchronous and it is possible to have one worker thread complete > multiple tasks before another worker thread completes one task. The > waiting thread must wait for all three worker threads to complete at > least one task, before doing its job. What is the best pthread > implementation for this problem? First, don't think about the threads that are doing the work, thing about the work itself. So change your question to look like this: We have three (possibly more) tasks that must be completed before we can start an additional task. What's the best way to start one task after some other set of tasks are complete? Because you don't care what threads do what tasks, you just need to get the tasks done in the appropriate order. There are several different ways to accomplish this, but the easiest is probably to make checking for what additional jobs can be done part of each of the other jobs. Alternatively, you can make a thread pool system that tracks the dependencies itself. Generally, I prefer the first solution. So that means each job includes a check at the end of it to see if any new jobs are now ready to be queued. DS .