title: notify_one() in c++ thread waking up more than one thread
body: <p>Hello I have the following code:</p>
  
  <pre><code>// condition_variable example
  #include &lt;iostream&gt;           // std::cout
  #include &lt;thread&gt;             // std::thread
  #include &lt;mutex&gt;              // std::mutex, std::unique_lock
  #include &lt;condition_variable&gt; // std::condition_variable
  
  std::mutex mtx;
  std::condition_variable cv;
  bool ready = false;
  
  void print_id (int id) {
    std::unique_lock&lt;std::mutex&gt; lock(mtx);
    while (!ready) cv.wait(lock);
    // ...
    std::cout &lt;&lt; "thread " &lt;&lt; id &lt;&lt; std::endl;
  }
  
  void go() {
    std::unique_lock&lt;std::mutex&gt; lock(mtx);
    ready = true;
    cv.notify_one();
  }
  
  int main ()
  {
    std::thread threads[10];
    // spawn 10 threads:
    for (int i=0; i&lt;10; ++i)
      threads[i] = std::thread(print_id,i);
  
    std::cout &lt;&lt; "10 threads ready to race..." &lt;&lt; std::endl;
    go();                       // go!
  
    for (auto&amp; th : threads) th.join();
    std::cout &lt;&lt; "Finished!" &lt;&lt; std::endl;
  
    return 0;
  }
  </code></pre>
  
  <p>And this is the output:</p>
  
  <pre><code>10 threads ready to race...
  thread 9
  thread 0
  </code></pre>
  
  <p>My expectation is that by calling notify_one(), only one thread will be notified and I will reach a deadlock. But in this case, two threads were notified before reching deadlock. What am I missing here? Thank you</p>