javolution37.javolution.util
Class ReentrantLock
- java.lang.Object
-
- javolution37.javolution.util.ReentrantLock
-
public class ReentrantLock extends java.lang.ObjectThis class represents a reentrant lock with the same semantics as built-in Java synchronized locks: Once a thread has a lock, it can re-obtain it any number of times without blocking.
-
-
Constructor Summary
Constructors Constructor and Description ReentrantLock()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.ThreadgetOwner()Returns the thread owner of thisReentrantLock.voidlock()Acquires the lock.booleantryLock()Acquires the lock only if it not held by another thread.voidunlock()Attempts to release this lock.
-
-
-
Method Detail
-
lock
public void lock()
Acquires the lock.
-
tryLock
public boolean tryLock()
Acquires the lock only if it not held by another thread.- Returns:
trueif the lock was free and was acquired by the current thread, or the lock was already held by the current thread;falseotherwise.
-
unlock
public void unlock()
Attempts to release this lock. The lock is actually released if at least as manyunlock()aslock()have been performed on thisReentrantLockby the current thread. throws IllegalMonitorStateExeception if the current thread does not hold this lock.
-
getOwner
public java.lang.Thread getOwner()
Returns the thread owner of thisReentrantLock.- Returns:
- the owner of this lock.
-
-
DMelt 3.0 © DataMelt by jWork.ORG