A Real Condition For A Condition Variable (Cont.) On the waiting side: /* lock the mutex. */ pthread_mutex_lock(&mutex); while (!q_size(q) > 0) { pthread_cond_wait(&cond, &mutex); } /* get first element off the queue. */ e = q->get_first(); /* unlock the mutex. */ pthread_mutex_unlock(&mutex); /* do something with the element */ handle_element(e);