Build 1.0_r1(from source)

Class ReentrantLock.Sync

  extended by java.util.concurrent.locks.AbstractQueuedSynchronizer
      extended by java.util.concurrent.locks.ReentrantLock.Sync
All Implemented Interfaces:
Direct Known Subclasses:
ReentrantLock.FairSync, ReentrantLock.NonfairSync
Enclosing class:

abstract static class ReentrantLock.Sync
extends AbstractQueuedSynchronizer

Base of synchronization control for this lock. Subclassed into fair and nonfair versions below. Uses AQS state to represent the number of holds on the lock.

Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject, AbstractQueuedSynchronizer.Node
Field Summary
(package private)  Thread owner
          Current owner thread
Constructor Summary
Method Summary
(package private)  int getHoldCount()
(package private)  Thread getOwner()
protected  boolean isHeldExclusively()
          Returns true if synchronization is held exclusively with respect to the current (calling) thread.
(package private)  boolean isLocked()
(package private) abstract  void lock()
          Perform Lock.lock().
(package private)  AbstractQueuedSynchronizer.ConditionObject newCondition()
(package private)  boolean nonfairTryAcquire(int acquires)
          Perform non-fair tryLock.
protected  boolean tryRelease(int releases)
          Attempts to set the state to reflect a release in exclusive mode.
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
acquire, acquireInterruptibly, acquireQueued, acquireShared, acquireSharedInterruptibly, compareAndSetState, fullyRelease, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isOnSyncQueue, isQueued, owns, release, releaseShared, setState, toString, transferAfterCancelledWait, transferForSignal, tryAcquire, tryAcquireNanos, tryAcquireShared, tryAcquireSharedNanos, tryReleaseShared
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


transient Thread owner
Current owner thread

Constructor Detail


Method Detail


abstract void lock()
Perform Lock.lock(). The main reason for subclassing is to allow fast path for nonfair version.


final boolean nonfairTryAcquire(int acquires)
Perform non-fair tryLock. tryAcquire is implemented in subclasses, but both need nonfair try for trylock method


protected final boolean tryRelease(int releases)
Description copied from class: AbstractQueuedSynchronizer
Attempts to set the state to reflect a release in exclusive mode.

This method is always invoked by the thread performing release.

The default implementation throws UnsupportedOperationException

tryRelease in class AbstractQueuedSynchronizer
releases - the release argument. This value is always the one passed to a release method, or the current state value upon entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
true if this object is now in a fully released state, so that any waiting threads may attempt to acquire; and false otherwise.


protected final boolean isHeldExclusively()
Description copied from class: AbstractQueuedSynchronizer
Returns true if synchronization is held exclusively with respect to the current (calling) thread. This method is invoked upon each call to a non-waiting AbstractQueuedSynchronizer.ConditionObject method. (Waiting methods instead invoke AbstractQueuedSynchronizer.release(int).)

The default implementation throws UnsupportedOperationException. This method is invoked internally only within AbstractQueuedSynchronizer.ConditionObject methods, so need not be defined if conditions are not used.

isHeldExclusively in class AbstractQueuedSynchronizer
true if synchronization is held exclusively; else false


final AbstractQueuedSynchronizer.ConditionObject newCondition()


final Thread getOwner()


final int getHoldCount()


final boolean isLocked()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature