--- jsr166/src/test/loops/PhaserLoops.java 2009/11/01 21:28:56 1.1 +++ jsr166/src/test/loops/PhaserLoops.java 2015/01/15 18:34:19 1.7 @@ -1,17 +1,16 @@ /* * 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/ */ import java.util.*; import java.util.concurrent.*; //import jsr166y.*; -/* +/** * Based loosely on Java Grande Forum barrierBench */ - public class PhaserLoops { static final int NCPUS = Runtime.getRuntime().availableProcessors(); static final ExecutorService pool = Executors.newCachedThreadPool(); @@ -31,11 +30,10 @@ public class PhaserLoops { phaser.register(); } - public void run() { int n = size; Phaser b = phaser; - for(int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) b.arriveAndAwaitAdvance(); } } @@ -44,20 +42,20 @@ public class PhaserLoops { int nthreads = NCPUS; if (args.length > 0) nthreads = Integer.parseInt(args[0]); - + System.out.printf("max %d Threads\n", nthreads); - + for (int k = 2; k <= nthreads; k *= 2) { for (int size = FIRST_SIZE; size <= LAST_SIZE; size *= 10) { long startTime = System.nanoTime(); - + Phaser phaser = new Phaser(); PhaserAction[] actions = new PhaserAction[nthreads]; for (int i = 0; i < k; ++i) { actions[i] = new PhaserAction(i, phaser, size); } - - Future[] futures = new Future[k]; + + Future[] futures = new Future[k]; for (int i = 0; i < k; ++i) { futures[i] = pool.submit(actions[i]); } @@ -72,7 +70,5 @@ public class PhaserLoops { } pool.shutdown(); } - -} - +}