80 * arrives, an optional action is performed and the phase
81 * advances. These actions are performed by the party
82 * triggering a phase advance, and are arranged by overriding
83 * method {@link #onAdvance(int, int)}, which also controls
84 * termination. Overriding this method is similar to, but more
85 * flexible than, providing a barrier action to a {@code
86 * CyclicBarrier}.
87 *
88 * <li><b>Waiting.</b> Method {@link #awaitAdvance} requires an
89 * argument indicating an arrival phase number, and returns when
90 * the phaser advances to (or is already at) a different phase.
91 * Unlike similar constructions using {@code CyclicBarrier},
92 * method {@code awaitAdvance} continues to wait even if the
93 * waiting thread is interrupted. Interruptible and timeout
94 * versions are also available, but exceptions encountered while
95 * tasks wait interruptibly or with timeout do not change the
96 * state of the phaser. If necessary, you can perform any
97 * associated recovery within handlers of those exceptions,
98 * often after invoking {@code forceTermination}. Phasers may
99 * also be used by tasks executing in a {@link ForkJoinPool}.
100 * Progress is ensured if the pool's parallelismLevel can
101 * accommodate the maximum number of simultaneously blocked
102 * parties.
103 *
104 * </ul>
105 *
106 * <p><b>Termination.</b> A phaser may enter a <em>termination</em>
107 * state, that may be checked using method {@link #isTerminated}. Upon
108 * termination, all synchronization methods immediately return without
109 * waiting for advance, as indicated by a negative return value.
110 * Similarly, attempts to register upon termination have no effect.
111 * Termination is triggered when an invocation of {@code onAdvance}
112 * returns {@code true}. The default implementation returns {@code
113 * true} if a deregistration has caused the number of registered
114 * parties to become zero. As illustrated below, when phasers control
115 * actions with a fixed number of iterations, it is often convenient
116 * to override this method to cause termination when the current phase
117 * number reaches a threshold. Method {@link #forceTermination} is
118 * also available to abruptly release waiting threads and allow them
119 * to terminate.
120 *
|
80 * arrives, an optional action is performed and the phase
81 * advances. These actions are performed by the party
82 * triggering a phase advance, and are arranged by overriding
83 * method {@link #onAdvance(int, int)}, which also controls
84 * termination. Overriding this method is similar to, but more
85 * flexible than, providing a barrier action to a {@code
86 * CyclicBarrier}.
87 *
88 * <li><b>Waiting.</b> Method {@link #awaitAdvance} requires an
89 * argument indicating an arrival phase number, and returns when
90 * the phaser advances to (or is already at) a different phase.
91 * Unlike similar constructions using {@code CyclicBarrier},
92 * method {@code awaitAdvance} continues to wait even if the
93 * waiting thread is interrupted. Interruptible and timeout
94 * versions are also available, but exceptions encountered while
95 * tasks wait interruptibly or with timeout do not change the
96 * state of the phaser. If necessary, you can perform any
97 * associated recovery within handlers of those exceptions,
98 * often after invoking {@code forceTermination}. Phasers may
99 * also be used by tasks executing in a {@link ForkJoinPool}.
100 * Progress is ensured if the pool's parallelism level can
101 * accommodate the maximum number of simultaneously blocked
102 * parties.
103 *
104 * </ul>
105 *
106 * <p><b>Termination.</b> A phaser may enter a <em>termination</em>
107 * state, that may be checked using method {@link #isTerminated}. Upon
108 * termination, all synchronization methods immediately return without
109 * waiting for advance, as indicated by a negative return value.
110 * Similarly, attempts to register upon termination have no effect.
111 * Termination is triggered when an invocation of {@code onAdvance}
112 * returns {@code true}. The default implementation returns {@code
113 * true} if a deregistration has caused the number of registered
114 * parties to become zero. As illustrated below, when phasers control
115 * actions with a fixed number of iterations, it is often convenient
116 * to override this method to cause termination when the current phase
117 * number reaches a threshold. Method {@link #forceTermination} is
118 * also available to abruptly release waiting threads and allow them
119 * to terminate.
120 *
|