public static class AutoLock.WithCondition extends 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();
}
AutoLock.WithCondition| 构造器和说明 |
|---|
WithCondition() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
await() |
boolean |
await(long time,
TimeUnit unit) |
AutoLock.WithCondition |
lock()
Acquires the lock.
|
void |
signal() |
void |
signalAll() |
close, isHeldByCurrentThread, newConditionpublic AutoLock.WithCondition lock()
AutoLockAcquires the lock.
public void signal()
Condition.signal()public void signalAll()
Condition.signalAll()public void await()
throws InterruptedException
InterruptedException - if the current thread is interruptedCondition.await()public boolean await(long time,
TimeUnit unit)
throws InterruptedException
time - the time to waitunit - the time unitInterruptedException - if the current thread is interruptedCondition.await(long, TimeUnit)Copyright © 2022. All rights reserved.