Build 1.0_r1(from source)

java.util.concurrent.locks
Class ReentrantLock.Sync

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

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
ReentrantLock.Sync()
           
 
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

owner

transient Thread owner
Current owner thread

Constructor Detail

ReentrantLock.Sync

ReentrantLock.Sync()
Method Detail

lock

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


nonfairTryAcquire

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


tryRelease

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

Overrides:
tryRelease in class AbstractQueuedSynchronizer
Parameters:
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.
Returns:
true if this object is now in a fully released state, so that any waiting threads may attempt to acquire; and false otherwise.

isHeldExclusively

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.

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

newCondition

final AbstractQueuedSynchronizer.ConditionObject newCondition()

getOwner

final Thread getOwner()

getHoldCount

final int getHoldCount()

isLocked

final boolean isLocked()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature