org.jpu.patterns.common
Class ReentrantLock

java.lang.Object
  extended byorg.jpu.patterns.common.ReentrantLock
All Implemented Interfaces:
IReentrantLock

public class ReentrantLock
extends java.lang.Object
implements IReentrantLock


Constructor Summary
ReentrantLock()
          Default constructor.
 
Method Summary
 java.lang.Thread getOwner()
          Returns the thread owner of this ReentrantLock.
 void lock()
          Acquires the lock.
 java.lang.String toString()
           
 boolean tryLock()
          Acquires the lock only if it not held by another thread.
 void unlock()
          Attempts to release this lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReentrantLock

public ReentrantLock()
Default constructor.

Method Detail

lock

public void lock()
Acquires the lock.

Specified by:
lock in interface IReentrantLock

tryLock

public boolean tryLock()
Acquires the lock only if it not held by another thread.

Specified by:
tryLock in interface IReentrantLock
Returns:
true if the lock was free and was acquired by the current thread, or the lock was already held by the current thread; false otherwise.

unlock

public void unlock()
Attempts to release this lock. The lock is actually released if at least as many unlock() as lock() have been performed on this ReentrantLock by the current thread. throws IllegalMonitorStateExeception if the current thread does not hold this lock.

Specified by:
unlock in interface IReentrantLock

toString

public java.lang.String toString()

getOwner

public java.lang.Thread getOwner()
Returns the thread owner of this ReentrantLock.

Specified by:
getOwner in interface IReentrantLock
Returns:
the owner of this lock.


Copyright (c) 2001-2003 - Apache Software Foundation