title: Control multithreaded flow with condition_variable
body: <p>I haven't wrapped my head around the C++11 multithreading stuff yet, but I'm trying to have multiple threads wait until some event on the main thread and then all continue at once (processing what happened), and <code>wait</code> again when they're done processing... looping until they're shut down. Below isn't exactly that - it's a simpler reproduction of my problem:</p>
  
  <pre><code>std::mutex mutex;
  std::condition_variable cv;
  
  std::thread thread1([&amp;](){ std::unique_lock&lt;std::mutex&gt; lock(mutex); cv.wait(lock);  std::cout &lt;&lt; "GO1!\n"; });
  std::thread thread2([&amp;](){ std::unique_lock&lt;std::mutex&gt; lock(mutex); cv.wait(lock);  std::cout &lt;&lt; "GO2!\n"; });
  
  cv.notify_all(); // Something happened - the threads can now process it
  
  thread1.join();
  thread2.join();
  </code></pre>
  
  <p>This works... unless I stop on some breakpoints and slow things down. When I do that I see <code>Go1!</code> and then hang, waiting for <code>thread2</code>'s <code>cv.wait</code>. What wrong?</p>
  
  <p>Maybe I shouldn't be using a condition variable anyway... there isn't any condition around the <code>wait</code>, nor is there data that needs protecting with a mutex. What should I do instead?</p>