Name

Package java.util.concurrent.locks

Synopsis

This package defines Lock and associated Condition interfaces as well as concrete implementations (such as ReentrantLock) that provide an alternative to locking with synchronized blocks and methods and to waiting with the wait( ), notify( ), and notifyAll( ) methods of Object.

Although Lock and Condition are somewhat more complex to use than the built-in locking, waiting, and notification mechanisms of Object, they are also more flexible. Lock, for example, does not require that locks be block-structured and enables algorithms such as “hand-over-hand locking” for traversing linked data structures. A thread waiting to acquire a Lock can time out or be interrupted, which is not possible with synchronized locking. Also, more than one Condition can be associated with a given Lock, which is simply not possible with Object-based locking and waiting.

The ReadWriteLock interface and its ReentrantReadWriteLock implementation allow multiple concurrent readers but only a single writer thread to hold the lock.

Interfaces

public interface Condition;
public interface Lock;
public interface ReadWriteLock;

Classes

public abstract class AbstractQueuedSynchronizer implements Serializable;
public class AbstractQueuedSynchronizer.ConditionObject implements Condition, Serializable;
public class LockSupport;
public class ReentrantLock implements Lock, Serializable;
public class ReentrantReadWriteLock implements ReadWriteLock, Serializable; public static class ...

Get Java in a Nutshell, 5th 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.