--- jsr166/src/test/loops/NoopSpinLockLoops.java 2009/10/29 23:09:07 1.3 +++ jsr166/src/test/loops/NoopSpinLockLoops.java 2014/12/31 17:00:58 1.7 @@ -1,13 +1,13 @@ /* * 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 java.util.concurrent.locks.*; import java.util.concurrent.atomic.*; -import java.util.*; +import java.util.concurrent.locks.*; public final class NoopSpinLockLoops { static final ExecutorService pool = Executors.newCachedThreadPool(); @@ -24,8 +24,7 @@ public final class NoopSpinLockLoops { new ReentrantLockLoop(1).test(); print = true; - int k = 1; - for (int i = 1; i <= maxThreads;) { + for (int k = 1, i = 1; i <= maxThreads;) { System.out.print("Threads: " + i); new ReentrantLockLoop(i).test(); Thread.sleep(100); @@ -59,9 +58,9 @@ public final class NoopSpinLockLoops { barrier.await(); if (print) { long time = timer.getTime(); - long tpi = time / ((long)iters * nthreads); + long tpi = time / ((long) iters * nthreads); System.out.print("\t" + LoopHelpers.rightJustify(tpi) + " ns per lock"); - double secs = (double)(time) / 1000000000.0; + double secs = (double) time / 1000000000.0; System.out.println("\t " + secs + "s run time"); }