Sometimes, when dealing with concurrent code, one task has to wait for another task to finish before it can finish itself. Tasks can signal one another through the
wait()/
notify()/
notifyAll() methods.
The
wait() method can be called in a loop checking a condition to make a task wait until the condition holds.
The
notify() and
notifyAll() methods can be used by a task that influences whether the condition holds, to make waiting tasks recheck the condition.
We now have the Concurrency API, with types such as Lock, CountDownLatch and Semaphore. If the language designers had added these in the first version of
Java, then they could have left the
wait(),
notify() and
notifyAll() methods out.