SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

serp.util
Class ThreadLock

java.lang.Object
  |
  +--serp.util.ThreadLock
All Implemented Interfaces:
Serializable

public class ThreadLock
extends Object
implements Serializable

Lock implementation. The lock is aware of the thread that owns it, and allows that thread to lock() multiple times without blocking. Only the owning thread can unlock(), and the lock will not be released to other threads until unlock() has been called the same number of times as lock().

Using this lock is similar to synchronizing on an object, but is more flexible (for example, the calls to lock() and unlock() can be surrounded by if statements).

Note that the lock resets on serialization.

See Also:
Serialized Form

Constructor Summary
ThreadLock()
           
 
Method Summary
 boolean isLocked()
          Return true if this lock is locked.
 void lock()
          Atomically lock.
 boolean lock(long timeout)
          Atomically lock.
 void unlock()
          Releases the lock.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLock

public ThreadLock()
Method Detail

lock

public void lock()
Atomically lock. Blocks until the lock is available.

lock

public boolean lock(long timeout)
Atomically lock. Blocks until the lock is available or a timeout occurs.
Returns:
true if the lock was obtained, false on timeout

unlock

public void unlock()
Releases the lock. This method can only be called by the owning thread.
Throws:
IllegalStateException - if current thread is not owner

isLocked

public boolean isLocked()
Return true if this lock is locked.

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.