Wait/Notify in Java
void notify(); /* signal */
void notifyAll(); /* broadcast */
public class PingPong (extends Object) {
public synchronized void PingPong() {
Every Java object may be treated as a condition variable for threads using its monitor.
A thread must own an object’s monitor to call wait/notify, else the method raises an IllegalMonitorStateException.
Wait(*) waits until the timeout elapses or another thread notifies, then it waits some more until it can re-obtain ownership of the monitor: Mesa semantics.