Subj : Re: pthread_cond_broadcast [a little long] To : comp.programming.threads From : David Schwartz Date : Tue Jan 25 2005 03:49 pm "fabrizio" wrote in message news:ct5e0k$rnb$1@utcnews.utc.fr... > I am trying to synchronize a certain number of threads > using condvars and encounter some problems. You have no predicate. > I create a thread that wait for x signals and then broadcast > a convar that should start all other threads. No, that's not how you use condition variables. > Unfortunately, as the last ready thread signal the ready condvar > the thread waiting for the ready event, immediately signal the start order > and the last thread has not yet reach the wait instruction. This is a common misunderstanding. 'pthread_cond_wait' is *not a conditional wait, it's an unconditional wait *for* a condition. It is vital that you call 'pthread_cond_wait' in a while loop (or similar), and it is vital that your program keep track of what it is that's being waited for. DS .