EDU.oswego.cs.dl.util.concurrent
Class ReentrantLock
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.ReentrantLock
- Sync
public class ReentrantLock
extends java.lang.Object
A lock with the same semantics as builtin
Java synchronized locks: Once a thread has a lock, it
can re-obtain it any number of times without blocking.
The lock is made available to other threads when
as many releases as acquires have occurred.
[
Introduction to this package. ]
void | acquire()
|
boolean | attempt(long msecs)
|
long | holds() - Return the number of unreleased acquires performed
by the current thread.
|
void | release() - Release the lock.
|
void | release(long n) - Release the lock N times.
|
holds_
protected long holds_
owner_
protected Thread owner_
acquire
public void acquire()
throws InterruptedException
- acquire in interface Sync
attempt
public boolean attempt(long msecs)
throws InterruptedException
- attempt in interface Sync
holds
public long holds()
Return the number of unreleased acquires performed
by the current thread.
Returns zero if current thread does not hold lock.
release
public void release()
Release the lock.
- release in interface Sync
release
public void release(long n)
Release the lock N times.
release(n)
is
equivalent in effect to:
for (int i = 0; i <32n; ++i) release();