Figure 2


(a) Waiting for a condition; (b) notifying when a condition has changed.

(a)
synchronized void doWhenCondition() {
    while (!condition)
        wait();
    ... Do what needs doing when the condition is true ...
}


(b)

synchronized void changeCondition() {
    ... change some value used in a condition test ...
    notify();
}