title: C - pthread condition variables
body: <p>So I have this while-loop that does some work with multiple threads and I want it to work as long as all threads are working, something like:</p>
  
  <pre><code>while(*threads are working*) {
   pthread_mutex_lock 
   if(stack is not empty) {
       pthread_cond_broadcast
       *critical work*
       pthread_mutex_unlock
   }
   else {
       pthread_cond_wait
       pthread_mutex_unlock
   }
  </code></pre>
  
  <p>I basically want this while-loop to run until ALL threads have checked if the stack is empty and are waiting in the else case. All tips are very welcome, thanks. </p>