title: Second thread doesn't wake up from cond_wait
body: <p>We are trying to find a good synchronization for Game of life.</p>
  
  <p>Therefore we have one printer thread and currently two threads that calculate the new generation of cells to be printed out next.</p>
  
  <p>The calculating threads can only start calculating the new generation of the game if the old one has already been printed.</p>
  
  <p>Therefore we use <code>pthread_cond_signal()</code> from the printer thread that is supposed to wake up both calculating threads.</p>
  
  <p><strong>For some reason only one thread wakes up at <code>pthread_cond_wait()</code></strong></p>
  
  <p>We already tried to use broadcast instead of signal, but that didn't have any effect.</p>
  
  <p>This is what our printer thread does:</p>
  
  <pre><code>field -&gt; printed = true;
  //pthread_mutex_unlock(&amp;(field -&gt; print_mutex));
  int status = pthread_cond_signal(&amp;(field -&gt; print_signal));
  </code></pre>
  
  <p>This is what our calculating threads do:</p>
  
  <pre><code>while(!field -&gt; printed){
      printf("waiting for print_signal: %d\n", field -&gt; printed);
      pthread_mutex_unlock(&amp;(field -&gt; print_mutex));
      pthread_cond_wait(&amp;(field -&gt; print_signal), &amp;(field -&gt; print_mutex));
      printf("print_signal received: %d\n", field -&gt; printed);
  }
  printf("print_signal received2: %d\n", field -&gt; printed);
  pthread_mutex_unlock(&amp;(field -&gt; print_mutex));
  </code></pre>
  
  <p>Afterwards the calculating threads do their calculation and wait till every thread completed before they set the field -> printed back to false.</p>
  
  <p>We feel like we still don't really understand how to use the mutex correctly.</p>