EDU.oswego.cs.dl.util.concurrent

Class ReentrantLock

public class ReentrantLock extends Object implements Sync

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. ]

Field Summary
protected longholds_
protected Threadowner_
Method Summary
voidacquire()
booleanattempt(long msecs)
longholds()
Return the number of unreleased acquires performed by the current thread.
voidrelease()
Release the lock.
voidrelease(long n)
Release the lock N times.

Field Detail

holds_

protected long holds_

owner_

protected Thread owner_

Method Detail

acquire

public void acquire()

attempt

public boolean attempt(long msecs)

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.

Throws: Error thrown if not current owner of lock

release

public void release(long n)
Release the lock N times. release(n) is equivalent in effect to:
   for (int i = 0; i < n; ++i) release();
 

Throws: Error thrown if not current owner of lock or has fewer than N holds on the lock