Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To protect against spurious wake ups. There is no guarantee made to you by the JVM that the only possible reason the thread will ever start running again is because you called signal in the way you intended. Sometimes it will just get started accidentally and go (Spurious wake up). So you have to keep waiting again if the condition you want to run on isn't actually true. </p> <p>This is explained in the javadoc for the wait method: <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait%28long%29" rel="noreferrer">http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait%28long%29</a></p> <p>And mentioned in the docs for await: <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/locks/Condition.html#await%28%29" rel="noreferrer">http://java.sun.com/javase/6/docs/api/java/util/concurrent/locks/Condition.html#await%28%29</a></p> <blockquote> <p>The lock associated with this Condition is atomically released and the current thread becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:</p> <ul> <li><p>Some other thread invokes the signal() method for this Condition and the current thread happens to be chosen as the thread to be awakened; or</p></li> <li><p>Some other thread invokes the signalAll() method for this Condition; or</p></li> <li><p>Some other thread interrupts the current thread, and interruption of thread suspension is supported; or</p></li> </ul> <p><strong>* A "spurious wakeup" occurs.</strong></p> </blockquote> <p>Some implementations of the Condition interface may suppress spurious wakeups, but relying on that would hence be relying on an implementation detail and makes your code unportable.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload