@ThreadSafe public class PhasedLatch extends Object implements ReusableLatch
PhasedLatch is a shared latch that
resets after it is released and can be reused. Potentially waiting threads
can test the current phase before performing an action. The action is then
guarded by that phase and can await that phase to be advanced via a call to
release the current phase.
This class is not final but cannot be sub-classed due to the private ctor.
| Modifier and Type | Method and Description |
|---|---|
void |
await()
Await the current phase.
|
boolean |
await(long time,
TimeUnit unit)
Await for the specified time for the condition to become true.
|
void |
awaitPhase(int phase)
Await the specified phase.
|
boolean |
awaitPhase(int phase,
long period,
TimeUnit unit)
Await the specified phase for the specified period.
|
int |
getPhase()
Get the current phase of the latch.
|
void |
release()
Release the current phase.
|
public final void release()
release in interface ReusableLatchpublic final void await()
throws InterruptedException
await in interface AwaitableInterruptedException - if interruptedpublic final boolean await(long time,
TimeUnit unit)
throws InterruptedException
await in interface Awaitabletime - the amount to wait.unit - the unit to wait in.InterruptedExceptionpublic final void awaitPhase(int phase)
throws InterruptedException
phase - the phase to wait forInterruptedException - if interruptedpublic final boolean awaitPhase(int phase,
long period,
TimeUnit unit)
throws InterruptedException
phase - the phase to wait forperiod - the period of time to wait for, as specified by:unit - of time to measure the period inInterruptedException - if interruptedpublic int getPhase()
Copyright © 2016 Atlassian. All rights reserved.