--- jsr166/src/test/loops/PhaserLoops.java 2009/11/01 21:28:56 1.1 +++ jsr166/src/test/loops/PhaserLoops.java 2012/10/21 06:40:21 1.5 @@ -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(); @@ -35,7 +34,7 @@ public class PhaserLoops { 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,19 +43,19 @@ 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]; for (int i = 0; i < k; ++i) { futures[i] = pool.submit(actions[i]); @@ -72,7 +71,5 @@ public class PhaserLoops { } pool.shutdown(); } - -} - +}