title: wait(long timeout) in a while loop?
body: <p>I've read that you're supposed to put <code>Object.wait()</code> calls in Java in a while loop. The reason is that this thread may be woken up and the condition that you were waiting to notify on is still false (spurious wake-up).</p>
  
  <p>What about <code>Object.wait(long timeout)</code>. Here, you don't want to loop on the condition since you want it to time out after the specified amount of time. But if you don't put it in a loop then how can you ensure that it won't be woken up early?</p>