org.norther.tammi.acorn.util.concurrent
Class TimeLimitedLock
java.lang.Object
org.norther.tammi.acorn.util.concurrent.TimeLimitedLock
- All Implemented Interfaces:
- Serializable, Lock
public class TimeLimitedLock
- extends Object
- implements Lock, Serializable
An adaptor class that lets any one thread to get a lock for a predetermined
time only. After the time has elapsed, the lock will be released and the next
waiting thread will get it. The lock and unlock must be made by the same
thread.
- Author:
- Ilkka Priha
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimeLimitedLock
public TimeLimitedLock(Lock l,
long t,
TimeUnit unit)
- Constructs a new lock adapter.
- Parameters:
l - the underlying lock.t - the timeout for locks.unit - the unit of the timeout.
lock
public void lock()
- Specified by:
lock in interface Lock
lockInterruptibly
public void lockInterruptibly()
throws InterruptedException
- Specified by:
lockInterruptibly in interface Lock
- Throws:
InterruptedException
tryLock
public boolean tryLock()
- Specified by:
tryLock in interface Lock
tryLock
public boolean tryLock(long t,
TimeUnit unit)
throws InterruptedException
- Specified by:
tryLock in interface Lock
- Throws:
InterruptedException
unlock
public void unlock()
- Specified by:
unlock in interface Lock
newCondition
public Condition newCondition()
- Specified by:
newCondition in interface Lock
Copyright © 2004 The Norther Organization. All rights reserved.