Condition

The java.util.concurrent.Condition interface is similar to the built-in wait(), notify(), and notifyAll() objects in functionality. Any implementation of Lock should create new Condition objects and return them as a result to the invocation of the newCondition() method. When the thread has a Condition, it can call await(), signal(), and signalAll() when the thread has the lock that created the condition object.

The functionality is very similar to the Object methods mentioned. The big difference is that you can create many Condition objects for a single Lock and they will work independently of one another, but not independent of the Lock.

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.