Waits for another thread to call notify() or notifyAll().
The lock MUST be held by the current thread before calling this method. This method MUST be called in a while loop to mitigate spurious wakeups.