diff options
Diffstat (limited to 'luni/src/main/java/java/util/concurrent/CyclicBarrier.java')
-rw-r--r-- | luni/src/main/java/java/util/concurrent/CyclicBarrier.java | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/luni/src/main/java/java/util/concurrent/CyclicBarrier.java b/luni/src/main/java/java/util/concurrent/CyclicBarrier.java index d5738c5..cf0b46e 100644 --- a/luni/src/main/java/java/util/concurrent/CyclicBarrier.java +++ b/luni/src/main/java/java/util/concurrent/CyclicBarrier.java @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ package java.util.concurrent; @@ -23,7 +23,8 @@ import java.util.concurrent.locks.*; * * <p><b>Sample usage:</b> Here is an example of * using a barrier in a parallel decomposition design: - * <pre> + * + * <pre> {@code * class Solver { * final int N; * final float[][] data; @@ -61,8 +62,8 @@ import java.util.concurrent.locks.*; * * waitUntilDone(); * } - * } - * </pre> + * }}</pre> + * * Here, each worker thread processes a row of the matrix then waits at the * barrier until all rows have been processed. When all rows are processed * the supplied {@link Runnable} barrier action is executed and merges the @@ -76,9 +77,10 @@ import java.util.concurrent.locks.*; * {@link #await} returns the arrival index of that thread at the barrier. * You can then choose which thread should execute the barrier action, for * example: - * <pre> if (barrier.await() == 0) { - * // log the completion of this iteration - * }</pre> + * <pre> {@code + * if (barrier.await() == 0) { + * // log the completion of this iteration + * }}</pre> * * <p>The <tt>CyclicBarrier</tt> uses an all-or-none breakage model * for failed synchronization attempts: If a thread leaves a barrier @@ -175,21 +177,21 @@ public class CyclicBarrier { throw new InterruptedException(); } - int index = --count; - if (index == 0) { // tripped - boolean ranAction = false; - try { - final Runnable command = barrierCommand; - if (command != null) - command.run(); - ranAction = true; - nextGeneration(); - return 0; - } finally { - if (!ranAction) - breakBarrier(); - } - } + int index = --count; + if (index == 0) { // tripped + boolean ranAction = false; + try { + final Runnable command = barrierCommand; + if (command != null) + command.run(); + ranAction = true; + nextGeneration(); + return 0; + } finally { + if (!ranAction) + breakBarrier(); + } + } // loop until tripped, broken, interrupted, or timed out for (;;) { @@ -325,7 +327,7 @@ public class CyclicBarrier { try { return dowait(false, 0L); } catch (TimeoutException toe) { - throw new Error(toe); // cannot happen; + throw new Error(toe); // cannot happen } } |