DZone

In my previous article, we learned how to use Wait and Notify methods in order to create a thread-safe blocking Queue. But in the described example we had only 1 consumer (John thread) and 1 producer (Peter thread). In this part, we consider another example with 2 consumers and 1 producer. The main purpose of this part is to learn to notify all functions and how Java Monitor handles this scenario.

Wait and NotifyAll Detailed Explanation

Let Me Introduce Three Main Thread

Participants: John1, John 2 (consumers), and Peter (producer)

Source: DZone