ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Phaser.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/Phaser.java (file contents):
Revision 1.78 by jsr166, Sun Jan 4 09:15:11 2015 UTC vs.
Revision 1.79 by jsr166, Tue Feb 17 18:55:39 2015 UTC

# Line 124 | Line 124 | import java.util.concurrent.locks.LockSu
124   * The typical idiom is for the method setting this up to first
125   * register, then start the actions, then deregister, as in:
126   *
127 < *  <pre> {@code
127 > * <pre> {@code
128   * void runTasks(List<Runnable> tasks) {
129   *   final Phaser phaser = new Phaser(1); // "1" to register self
130   *   // create and start threads
# Line 145 | Line 145 | import java.util.concurrent.locks.LockSu
145   * <p>One way to cause a set of threads to repeatedly perform actions
146   * for a given number of iterations is to override {@code onAdvance}:
147   *
148 < *  <pre> {@code
148 > * <pre> {@code
149   * void startTasks(List<Runnable> tasks, final int iterations) {
150   *   final Phaser phaser = new Phaser() {
151   *     protected boolean onAdvance(int phase, int registeredParties) {
# Line 169 | Line 169 | import java.util.concurrent.locks.LockSu
169   *
170   * If the main task must later await termination, it
171   * may re-register and then execute a similar loop:
172 < *  <pre> {@code
172 > * <pre> {@code
173   *   // ...
174   *   phaser.register();
175   *   while (!phaser.isTerminated())
# Line 179 | Line 179 | import java.util.concurrent.locks.LockSu
179   * in contexts where you are sure that the phase will never wrap around
180   * {@code Integer.MAX_VALUE}. For example:
181   *
182 < *  <pre> {@code
182 > * <pre> {@code
183   * void awaitPhase(Phaser phaser, int phase) {
184   *   int p = phaser.register(); // assumes caller not already registered
185   *   while (p < phase) {
# Line 199 | Line 199 | import java.util.concurrent.locks.LockSu
199   * new Phaser())}, these tasks could then be started, for example by
200   * submitting to a pool:
201   *
202 < *  <pre> {@code
202 > * <pre> {@code
203   * void build(Task[] tasks, int lo, int hi, Phaser ph) {
204   *   if (hi - lo > TASKS_PER_PHASER) {
205   *     for (int i = lo; i < hi; i += TASKS_PER_PHASER) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines