|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Barrier
Barriers serve as synchronization points for groups of threads that must occasionally wait for each other. Barriers may support any of several methods that accomplish this synchronization. This interface merely expresses their minimal commonalities:
parties -- the number of threads that must meet at
the barrier point. (In all current implementations, this value is fixed upon construction of the Barrier.)
broken if one or more threads leave a barrier point prematurely, generally due
to interruption or timeout. Corresponding synchronization methods in barriers fail, throwing BrokenBarrierException
for other threads when barriers are in broken states.
[ Introduction to this package. ]
| Method Summary | |
|---|---|
int |
await()
Enter barrier and wait for the other parties()-1 threads. |
int |
await(long msecs)
Enter barrier and wait at most msecs for the other parties()-1 threads. |
int |
getParties()
Return the number of parties that must meet per barrier point. |
boolean |
isBroken()
Returns true if the barrier has been compromised by threads leaving the barrier before a synchronization point (normally due to interruption or timeout). |
void |
reset()
Reset to initial state. |
| Method Detail |
|---|
int getParties()
boolean isBroken()
int await()
throws InterruptedException,
BrokenBarrierException
BrokenBarrierException - if any other thread in any previous or current barrier since either creation or
the last restart operation left the barrier prematurely due to interruption or time-out.
(If so, the broken status is also set.) Threads that are notified to have been interrupted
after being released are not considered to have broken the barrier. In all cases, the
interruption status of the current thread is preserved, so can be tested by checking
Thread.interrupted.
InterruptedException - if this thread was interrupted during the barrier, and was the one causing
breakage. If so, broken status is also set.
int await(long msecs)
throws InterruptedException,
TimeoutException,
BrokenBarrierException
BrokenBarrierException - if any other thread in any previous or current barrier since either creation or
the last restart operation left the barrier prematurely due to interruption or time-out.
(If so, the broken status is also set.) Threads that are noticed to have been interrupted
after being released are not considered to have broken the barrier. In all cases, the
interruption status of the current thread is preserved, so can be tested by checking
Thread.interrupted.
InterruptedException - if this thread was interrupted during the barrier. If so, broken
status is also set.
TimeoutException - if this thread timed out waiting for the barrier. If the timeout occured while already
in the barrier, broken status is also set.void reset()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||