Package com.aspectran.utils.thread
Class AutoLock.WithCondition
java.lang.Object
com.aspectran.utils.thread.AutoLock
com.aspectran.utils.thread.AutoLock.WithCondition
- All Implemented Interfaces:
Serializable
,AutoCloseable
- Enclosing class:
AutoLock
A reentrant lock with a condition that can be used in a try-with-resources statement.
Typical usage:
// Waiting try (AutoLock lock = _lock.lock()) { lock.await(); } // Signaling try (AutoLock lock = _lock.lock()) { lock.signalAll(); }
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.aspectran.utils.thread.AutoLock
AutoLock.WithCondition
-
Constructor Summary
-
Method Summary
Methods inherited from class com.aspectran.utils.thread.AutoLock
close, isHeldByCurrentThread, newCondition
-
Constructor Details
-
WithCondition
public WithCondition()
-
-
Method Details
-
lock
Description copied from class:AutoLock
Acquires the lock. -
signal
public void signal()- See Also:
-
signalAll
public void signalAll()- See Also:
-
await
- Throws:
InterruptedException
- if the current thread is interrupted- See Also:
-
await
- Parameters:
time
- the time to waitunit
- the time unit- Returns:
- false if the waiting time elapsed
- Throws:
InterruptedException
- if the current thread is interrupted- See Also:
-