When to use wait()/notify() in Java?

If you are using a version prior to Java 5, then the wait/notify mechanism can be a key part of thread programming. It is generally used in situations where you need to communicate between two threads. This includes cases such as the following:

Wait()/notify() in Java 5

As of Java 5, there is less need for programmers to use wait()/notify(), since other classes are available in the Java concurrency package (java.util.concurrent) to handle these common situations. For example:

Next: how to use wait/notify

On the next page, we'll continue by looking at how to use wait/notify in Java.