84 |
|
* model for failed synchronization attempts: If a thread leaves a |
85 |
|
* barrier point prematurely because of interruption, failure, or |
86 |
|
* timeout, all other threads, even those that have not yet resumed |
87 |
< |
* from a previous {@link await}. will also leave abnormally via |
87 |
> |
* from a previous {@link #await}. will also leave abnormally via |
88 |
|
* {@link BrokenBarrierException} (or <tt>InterruptedException</tt> if |
89 |
|
* they too were interrupted at about the same time). |
90 |
|
* |
268 |
|
* interrupted status is cleared. |
269 |
|
* |
270 |
|
* <p>If the barrier is {@link #reset} while any thread is waiting, or if |
271 |
< |
* the barrier {@link #isBroken is broken} when <tt>await</tt> is invoked |
271 |
> |
* the barrier {@link #isBroken is broken} when <tt>await</tt> is invoked, |
272 |
> |
* or whilst any thread is waiting, |
273 |
|
* then {@link BrokenBarrierException} is thrown. |
274 |
|
* |
275 |
|
* <p>If any thread is {@link Thread#interrupt interrupted} while waiting, |
282 |
|
* current thread runs the action before allowing the other threads to |
283 |
|
* continue. |
284 |
|
* If an exception occurs during the barrier action then that exception |
285 |
< |
* will be propagated in the current thread. |
285 |
> |
* will be propagated in the current thread and the barrier is placed in |
286 |
> |
* the broken state. |
287 |
|
* |
288 |
|
* @return the arrival index of the current thread, where index |
289 |
|
* <tt>{@link #getParties()} - 1</tt> indicates the first to arrive and |
313 |
|
* one of the following things happens: |
314 |
|
* <ul> |
315 |
|
* <li>The last thread arrives; or |
316 |
< |
* <li>The speceified timeout elapses; or |
316 |
> |
* <li>The specified timeout elapses; or |
317 |
|
* <li>Some other thread {@link Thread#interrupt interrupts} the current |
318 |
|
* thread; or |
319 |
|
* <li>Some other thread {@link Thread#interrupt interrupts} one of the |
330 |
|
* interrupted status is cleared. |
331 |
|
* |
332 |
|
* <p>If the barrier is {@link #reset} while any thread is waiting, or if |
333 |
< |
* the barrier {@link #isBroken is broken} when <tt>await</tt> is invoked |
333 |
> |
* the barrier {@link #isBroken is broken} when <tt>await</tt> is invoked, |
334 |
> |
* or whilst any thread is waiting, |
335 |
|
* then {@link BrokenBarrierException} is thrown. |
336 |
|
* |
337 |
|
* <p>If any thread is {@link Thread#interrupt interrupted} while waiting, |
344 |
|
* current thread runs the action before allowing the other threads to |
345 |
|
* continue. |
346 |
|
* If an exception occurs during the barrier action then that exception |
347 |
< |
* will be propagated in the current thread. |
347 |
> |
* will be propagated in the current thread and the barrier is placed in |
348 |
> |
* the broken state. |
349 |
|
* |
350 |
|
* @param timeout the time to wait for the barrier |
351 |
|
* @param unit the time unit of the timeout parameter |
372 |
|
* Query if this barrier is in a broken state. |
373 |
|
* @return <tt>true</tt> if one or more parties broke out of this |
374 |
|
* barrier due to interruption or timeout since construction or |
375 |
< |
* the last reset; and <tt>false</tt> otherwise. |
375 |
> |
* the last reset, or a barrier action failed due to an exception; |
376 |
> |
* and <tt>false</tt> otherwise. |
377 |
|
*/ |
378 |
|
public boolean isBroken() { |
379 |
|
lock.lock(); |