--- jsr166/src/test/loops/ConcurrentQueueLoops.java 2009/11/02 23:42:46 1.8 +++ jsr166/src/test/loops/ConcurrentQueueLoops.java 2014/12/18 18:13:06 1.15 @@ -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/ */ import java.util.*; @@ -50,8 +50,7 @@ public class ConcurrentQueueLoops { Thread.sleep(100); print = true; - int k = 1; - for (int i = 1; i <= maxStages;) { + for (int k = 1, i = 1; i <= maxStages;) { oneRun(klass, i); if (i == k) { k = i << 1; @@ -61,13 +60,13 @@ public class ConcurrentQueueLoops { i = k; } pool.shutdown(); - } + } static final class Stage implements Callable { final Queue queue; final CyclicBarrier barrier; final int nthreads; - Stage (Queue q, CyclicBarrier b, int nthreads) { + Stage(Queue q, CyclicBarrier b, int nthreads) { queue = q; barrier = b; this.nthreads = nthreads; @@ -75,8 +74,8 @@ public class ConcurrentQueueLoops { static int compute(int l) { if (l == 0) - return (int)System.nanoTime(); - int nn = (l >>> 7) & workMask; + return (int) System.nanoTime(); + int nn = (l >>> 7) & workMask; while (nn-- > 0) l = LoopHelpers.compute6(l); return l; @@ -87,7 +86,7 @@ public class ConcurrentQueueLoops { barrier.await(); long now = System.nanoTime(); long stopTime = now + RUN_TIME_NANOS; - int l = (int)now; + int l = (int) now; int takes = 0; int misses = 0; int lmask = 1; @@ -118,7 +117,7 @@ public class ConcurrentQueueLoops { } static void oneRun(Class klass, int n) throws Exception { - Queue q = (Queue)klass.newInstance(); + Queue q = (Queue) klass.newInstance(); LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); CyclicBarrier barrier = new CyclicBarrier(n + 1, timer); ArrayList> results = new ArrayList>(n);