Package org.eclipse.jetty.util.thread
Class AutoLock.WithCondition
java.lang.Object
org.eclipse.jetty.util.thread.AutoLock
org.eclipse.jetty.util.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 org.eclipse.jetty.util.thread.AutoLock
AutoLock.WithCondition
-
Constructor Summary
-
Method Summary
Methods inherited from class org.eclipse.jetty.util.thread.AutoLock
close, isHeldByCurrentThread, newCondition
-
Constructor Details
-
WithCondition
public WithCondition()
-
-
Method Details
-
lock
Description copied from class:AutoLock
Acquires the lock.
-
tryLock
Description copied from class:AutoLock
Tries to acquire the lock.
Whether the lock was acquired can be tested with
AutoLock.isHeldByCurrentThread()
.Typical usage of this method is in
toString()
, to avoid deadlocks when the implementation needs to lock to retrieve a consistent state to produce the string. -
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:
-