How to differentiate when wait(long timeout) exit for notify or timeout?
There is one more reason that notify can return: spurious wakeup. This is an unlikely but possible thing, because preventing spurious wakeups is very expensive on some hardware/OS combinations. Because of this you always have to call wait() in a loop and re-check the condition that you are waiting for. During this work it’s easy … Read more