--- jsr166/src/test/loops/CASLoops.java 2009/10/29 23:09:07 1.4 +++ jsr166/src/test/loops/CASLoops.java 2015/01/15 18:34:18 1.10 @@ -1,6 +1,6 @@ /* * Written by Doug Lea and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ /* @@ -26,11 +26,10 @@ * if this program is called with (any) second argument */ - +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.*; public class CASLoops { @@ -46,7 +45,7 @@ public class CASLoops { if (args.length > 0) maxThreads = Integer.parseInt(args[0]); - loopIters = new long[maxThreads+1]; + loopIters = new long[maxThreads+1]; if (args.length > 1) includeLocks = true; @@ -115,7 +114,6 @@ public class CASLoops { valueUpdater = AtomicIntegerFieldUpdater.newUpdater (UpdaterAtomicInteger.class, "value"); - UpdaterAtomicInteger() {} int get() { return value; @@ -161,7 +159,6 @@ public class CASLoops { synchronized void set(int val) { value = val; } } - static final class LockedInteger extends AbstractQueuedSynchronizer { int value; LockedInteger() {} @@ -537,7 +534,6 @@ public class CASLoops { return timer.getTime(); } - static long runSynched(int n, long iters) throws Exception { LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); CyclicBarrier b = new CyclicBarrier(n+1, timer); @@ -569,17 +565,16 @@ public class CASLoops { if (nthreads > NCPUS) t = t * NCPUS / nthreads; System.out.print(LoopHelpers.rightJustify(t)); - double secs = (double)(runtime) / 1000000000.0; + double secs = (double) runtime / 1000000000.0; System.out.println("\t " + secs + "s run time"); } - static void oneRun(int i, long iters, boolean print) throws Exception { if (print) System.out.println("threads : " + i + " base iters per thread per run : " + LoopHelpers.rightJustify(loopIters[i])); - long ntime = runNonAtomic(i, iters); + long ntime = runNonAtomic(i, iters); if (print) report("Base : ", ntime, ntime, i, iters); Thread.sleep(100L); @@ -606,6 +601,4 @@ public class CASLoops { report("Synchronized: ", stime, ntime, i, iters); Thread.sleep(100L); } - - }