title: Do spurious wakeups in Java actually happen?
body: <p>Seeing various locking related question and (almost) always finding the 'loop because of spurious wakeups' terms<sup>1</sup> I wonder, has anyone experienced such kind of a wakeup (assuming a decent hardware/software environment for example)?</p>
  
  <p>I know the term 'spurious' means no apparent reason but what can be the reasons for such kind of an event?</p>
  
  <p>(<sup>1</sup> Note: I'm not questioning the looping practice.)</p>
  
  <p><strong>Edit:</strong> A helper question (for those who like code samples):</p>
  
  <p>If I have the following program, and I run it:</p>
  
  <pre><code>public class Spurious {
      public static void main(String[] args) {
          Lock lock = new ReentrantLock();
          Condition cond = lock.newCondition();
          lock.lock();
          try {
              try {
                  cond.await();
                  System.out.println("Spurious wakeup!");
              } catch (InterruptedException ex) {
                  System.out.println("Just a regular interrupt.");
              }
          } finally {
              lock.unlock();
          }
      }
  }
  </code></pre>
  
  <p>What can I do to wake this <code>await</code> up spuriously without waiting forever for a random event?</p>