1
JavaAdvanced#design-patterns
Object methods used for inter-thread communication. wait() releases the monitor and pauses the thread. notify() wakes one waiting thread, notifyAll() wakes all. Must be called inside a synchronized block.
synchronized (lock) {
while (!ready) lock.wait();
// proceed once notified
}
// on the other thread:
synchronized (lock) { ready = true; lock.notifyAll(); }