...
To guarantee liveness, the while
loop condition must be tested before invoking the wait()
method. This is in case another thread has already satisfied the condition predicate and sent a notification. Invoking the wait()
method after the notify signal notification has been sent results in indefinite blocking.
...