public final class OneShotLatch extends Object
| 构造器和说明 |
|---|
OneShotLatch() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
await()
Waits until
trigger() is called. |
void |
await(long timeout,
TimeUnit timeUnit)
Waits until
trigger() is called. |
int |
getWaitersCount() |
boolean |
isTriggered()
Checks if the latch was triggered.
|
void |
reset()
Resets the latch so that
isTriggered() returns false. |
String |
toString() |
void |
trigger()
Fires the latch.
|
public void trigger()
await() will now return.public void await()
throws InterruptedException
trigger() is called. Once trigger() has been called
this call will always return immediately.InterruptedException - Thrown if the thread is interrupted while waiting.public void await(long timeout,
TimeUnit timeUnit)
throws InterruptedException,
TimeoutException
trigger() is called. Once #trigger() has been called
this call will always return immediately.
If the latch is not triggered within the given timeout, a TimeoutException will be
thrown after the timeout.
A timeout value of zero means infinite timeout and make this equivalent to await().
timeout - The value of the timeout, a value of zero indicating infinite timeout.timeUnit - The unit of the timeoutInterruptedException - Thrown if the thread is interrupted while waiting.TimeoutException - Thrown, if the latch is not triggered within the timeout time.public boolean isTriggered()
public int getWaitersCount()
public void reset()
isTriggered() returns false.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.