See:
Description
Interface Summary | |
---|---|
Condition | Condition factors out the Object monitor methods ( wait , notify and notifyAll ) into distinct objects to give the effect of having multiple wait-sets per object, by combining them with the use of arbitrary Lock implementations. |
Lock | Lock implementations provide more extensive locking operations than can be obtained using synchronized methods and statements. |
ReadWriteLock | A ReadWriteLock maintains a pair of associated locks , one for read-only operations and one for writing. |
Class Summary | |
---|---|
AbstractOwnableSynchronizer | A synchronizer that may be exclusively owned by a thread. |
AbstractQueuedLongSynchronizer | A version of AbstractQueuedSynchronizer long . |
AbstractQueuedSynchronizer | Provides a framework for implementing blocking locks and related synchronizers (semaphores, events, etc) that rely on first-in-first-out (FIFO) wait queues. |
LockSupport | Basic thread blocking primitives for creating locks and other synchronization classes. |
ReentrantLock | A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor lock accessed using synchronized methods and statements, but with extended capabilities. |
ReentrantReadWriteLock | An implementation of ReadWriteLock supporting similar semantics to ReentrantLock . |
ReentrantReadWriteLock.ReadLock | The lock returned by method ReentrantReadWriteLock.readLock() . |
ReentrantReadWriteLock.WriteLock | The lock returned by method ReentrantReadWriteLock.writeLock() . |
Interfaces and classes providing a framework for locking and waitingfor conditions that is distinct from built-in synchronization andmonitors. The framework permits much greater flexibility in the use oflocks and conditions, at the expense of more awkward syntax.
The Lock interface supportslocking disciplines that differ in semantics (reentrant, fair, etc),and that can be used in non-block-structured contexts includinghand-over-hand and lock reordering algorithms. The main implementationis ReentrantLock .
The ReadWriteLock interfacesimilarly defines locks that may be shared among readers but areexclusive to writers. Only a single implementation, ReentrantReadWriteLock , is provided, sinceit covers most standard usage contexts. But programmers may createtheir own implementations to cover nonstandard requirements.
The Condition interfacedescribes condition variables that may be associated with Locks.These are similar in usage to the implicit monitors accessed using Object.wait , but offer extended capabilities. In particular,multiple Condition objects may be associated with a single Lock . To avoid compatibility issues, the names of Condition methods are different than the corresponding Object versions.
The
AbstractQueuedSynchronizer
class serves as a useful superclass for defining locks and othersynchronizers that rely on queuing blocked threads.
The
AbstractQueuedLongSynchronizer
classprovides the same functionality but extends support to 64 bits ofsynchronization state. Both extend class
AbstractOwnableSynchronizer
, a simpleclass that helps record the thread currently holding exclusivesynchronization.
The
LockSupport
class provides
lower-level blocking
lower-levelblocking
and unblocking support that
isuseful
is useful
for those
developers implementing
developersimplementing
their own customized
lockclasses.
lock classes.