If a notification is sent and no thread is waiting, then the notification is lost.
This is why
you should never use wait/notify without some sort of flag. Basically:
- Never call wait unless you need to. If the notify flag runs first, the notification may be lost, but the first thread won't wait, because the flag should be set.
- Never expect the flag to be set upon return from wait() -- another thread may have done the first point, and not performed a wait.
Henry