Java.Util.Concurrent.Locks Namespace

The Java.Util.Concurrent.Locks.ILock interface supports locking disciplines that differ in semantics (reentrant, fair, etc), and that can be used in non-block-structured contexts including hand-over-hand and lock reordering algorithms.

Remarks

Interfaces and classes providing a framework for locking and waiting for conditions that is distinct from built-in synchronization and monitors. The framework permits much greater flexibility in the use of locks and conditions, at the expense of more awkward syntax.

The Java.Util.Concurrent.Locks.ILock interface supports locking disciplines that differ in semantics (reentrant, fair, etc), and that can be used in non-block-structured contexts including hand-over-hand and lock reordering algorithms. The main implementation is Java.Util.Concurrent.Locks.ReentrantLock.

The Java.Util.Concurrent.Locks.IReadWriteLock interface similarly defines locks that may be shared among readers but are exclusive to writers. Only a single implementation, Java.Util.Concurrent.Locks.ReentrantReadWriteLock, is provided, since it covers most standard usage contexts. But programmers may create their own implementations to cover nonstandard requirements.

The Java.Util.Concurrent.Locks.ICondition interface describes 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 from the corresponding Object versions.

The Java.Util.Concurrent.Locks.AbstractQueuedSynchronizer class serves as a useful superclass for defining locks and other synchronizers that rely on queuing blocked threads. The Java.Util.Concurrent.Locks.AbstractQueuedLongSynchronizer class provides the same functionality but extends support to 64 bits of synchronization state. Both extend class Java.Util.Concurrent.Locks.AbstractOwnableSynchronizer, a simple class that helps record the thread currently holding exclusive synchronization. The Java.Util.Concurrent.Locks.LockSupport class provides lower-level blocking and unblocking support that is useful for those developers implementing their own customized lock classes.

Classes

TypeReason
AbstractOwnableSynchronizerA synchronizer that may be exclusively owned by a thread.
AbstractQueuedLongSynchronizerA version of Java.Util.Concurrent.Locks.AbstractQueuedSynchronizer in which synchronization state is maintained as a long.
AbstractQueuedLongSynchronizer+ConditionObjectCondition implementation for a Java.Util.Concurrent.Locks.AbstractQueuedLongSynchronizer serving as the basis of a Java.Util.Concurrent.Locks.ILock implementation.
AbstractQueuedSynchronizerProvides a framework for implementing blocking locks and related synchronizers (semaphores, events, etc) that rely on first-in-first-out (FIFO) wait queues.
AbstractQueuedSynchronizer+ConditionObjectCondition implementation for a Java.Util.Concurrent.Locks.AbstractQueuedSynchronizer serving as the basis of a Java.Util.Concurrent.Locks.ILock implementation.
ICondition Condition factors out the Object monitor methods (Java.Lang.Object.Wait, Java.Lang.Object.Notify and Java.Lang.Object.NotifyAll) into distinct objects to give the effect of having multiple wait-sets per object, by combining them with the use of arbitrary Java.Util.Concurrent.Locks.ILock implementations.
ILock Lock implementations provide more extensive locking operations than can be obtained using synchronized methods and statements.
IReadWriteLockA ReadWriteLock maintains a pair of associated Java.Util.Concurrent.Locks.ILock, one for read-only operations and one for writing.
LockSupportBasic thread blocking primitives for creating locks and other synchronization classes.
ReentrantLockA reentrant mutual exclusion Java.Util.Concurrent.Locks.ILock with the same basic behavior and semantics as the implicit monitor lock accessed using synchronized methods and statements, but with extended capabilities.
ReentrantReadWriteLockAn implementation of Java.Util.Concurrent.Locks.IReadWriteLock supporting similar semantics to Java.Util.Concurrent.Locks.ReentrantLock.
ReentrantReadWriteLock+ReentrantReadLockThe lock returned by method Java.Util.Concurrent.Locks.ReentrantReadWriteLock.ReadLock.
ReentrantReadWriteLock+ReentrantWriteLockThe lock returned by method Java.Util.Concurrent.Locks.ReentrantReadWriteLock.WriteLock.