API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util.concurrent.locks. ReentrantLock View Source
Author(s)
Doug Lea
Since
1.5
Version
Serial
Hierarchy
 Object
      ReentrantLock
Implements
 Lock
 Serializable
Subclasses
Description
public class 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.
See also:   
Constructors
public ReentrantLock ()
  Creates an instance of ReentrantLock.
public ReentrantLock (boolean fair)
  Creates an instance of ReentrantLock with the given fairness policy.
Methods
Hide/Show inherited methods
public int getHoldCount ()
  Queries the number of holds on this lock by the current thread.
protected Thread getOwner ()
  Returns the thread that currently owns this lock, or null if not owned.
protected Collection<Thread> getQueuedThreads ()
  Returns a collection containing threads that may be waiting to acquire this lock.
publicfinal int getQueueLength ()
  Returns an estimate of the number of threads waiting to acquire this lock.
protected Collection<Thread> getWaitingThreads (Condition condition)
  Returns a collection containing those threads that may be waiting on the given condition associated with this lock.
public int getWaitQueueLength (Condition condition)
  Returns an estimate of the number of threads waiting on the given condition associated with this lock.
publicfinal boolean hasQueuedThread (Thread thread)
  Queries whether the given thread is waiting to acquire this lock.
publicfinal boolean hasQueuedThreads ()
  Queries whether any threads are waiting to acquire this lock.
public boolean hasWaiters (Condition condition)
  Queries whether any threads are waiting on the given condition associated with this lock.
publicfinal boolean isFair ()
  Returns true if this lock has fairness set true.
public boolean isHeldByCurrentThread ()
  Queries if this lock is held by the current thread.
public boolean isLocked ()
  Queries if this lock is held by any thread.
public void lock () [Specified in Lock]
  Acquires the lock.
public void lockInterruptibly () throws InterruptedException [Specified in Lock]
  Acquires the lock unless the current thread is interrupted.
public Condition newCondition () [Specified in Lock]
  Returns a Condition instance for use with this Lock instance.
public String toString ()
  Returns a string identifying this lock, as well as its lock state.
public boolean tryLock () [Specified in Lock]
  Acquires the lock only if it is not held by another thread at the time of invocation.
public boolean tryLock (long timeout, TimeUnit unit) throws InterruptedException [Specified in Lock]
  Acquires the lock if it is not held by another thread within the given waiting time and the current thread has not been interrupted.
public void unlock () [Specified in Lock]
  Attempts to release this lock.
Fields
Hide/Show inherited fields
Nested Classes
  ReentrantLock.Sync
Base of synchronization control for this lock.
  ReentrantLock.NonfairSync
Sync object for non-fair locks
  ReentrantLock.FairSync
Sync object for fair locks
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar