# java.util.concurrent.locks

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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html` 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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantLock.html`.

The `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReadWriteLock.html` interface
similarly defines locks that may be shared among readers but are
exclusive to writers. Only a single implementation, `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.html`, is provided, since
it covers most standard usage contexts. But programmers may create
their own implementations to cover nonstandard requirements.

The `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Condition.html` 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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.html`
class serves as a useful superclass for defining locks and other
synchronizers that rely on queuing blocked threads. The `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.html` class
provides the same functionality but extends support to 64 bits of
synchronization state. Both extend class `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractOwnableSynchronizer.html`, a simple
class that helps record the thread currently holding exclusive
synchronization. The `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/LockSupport.html`
class provides lower-level blocking and unblocking support that is
useful for those developers implementing their own customized lock
classes.

### Interfaces

|---|---|
| [Condition](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Condition.html) | `Condition` factors out the `Object` monitor methods (`https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait()`, `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify()` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll()`) into distinct objects to give the effect of having multiple wait-sets per object, by combining them with the use of arbitrary `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html` implementations. |
| [Lock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html) | `Lock` implementations provide more extensive locking operations than can be obtained using `synchronized` methods and statements. |
| [ReadWriteLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReadWriteLock.html) | A `ReadWriteLock` maintains a pair of associated `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html`, one for read-only operations and one for writing. |

### Classes

|---|---|
| [AbstractOwnableSynchronizer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractOwnableSynchronizer.html) | A synchronizer that may be exclusively owned by a thread. |
| [AbstractQueuedLongSynchronizer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.html) | A version of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.html` in which synchronization state is maintained as a `long`. |
| [AbstractQueuedLongSynchronizer.ConditionObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject.html) | Condition implementation for a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.html` serving as the basis of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html` implementation. |
| [AbstractQueuedSynchronizer](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.html) | Provides a framework for implementing blocking locks and related synchronizers (semaphores, events, etc) that rely on first-in-first-out (FIFO) wait queues. |
| [AbstractQueuedSynchronizer.ConditionObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.ConditionObject.html) | Condition implementation for a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/AbstractQueuedSynchronizer.html` serving as the basis of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html` implementation. |
| [LockSupport](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/LockSupport.html) | Basic thread blocking primitives for creating locks and other synchronization classes. |
| [ReentrantLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantLock.html) | A reentrant mutual exclusion `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/Lock.html` with the same basic behavior and semantics as the implicit monitor lock accessed using `synchronized` methods and statements, but with extended capabilities. |
| [ReentrantReadWriteLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.html) | An implementation of `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReadWriteLock.html` supporting similar semantics to `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantLock.html`. |
| [ReentrantReadWriteLock.ReadLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.ReadLock.html) | The lock returned by method `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.html#readLock()`. |
| [ReentrantReadWriteLock.WriteLock](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.WriteLock.html) | The lock returned by method `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/locks/ReentrantReadWriteLock.html#writeLock()`. |