--- jsr166/src/test/loops/SimpleWriteLockLoops.java 2007/02/19 00:46:06 1.3 +++ jsr166/src/test/loops/SimpleWriteLockLoops.java 2014/12/31 17:00:58 1.7 @@ -1,12 +1,12 @@ /* * 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.*; public final class SimpleWriteLockLoops { static final ExecutorService pool = Executors.newCachedThreadPool(); @@ -16,7 +16,7 @@ public final class SimpleWriteLockLoops public static void main(String[] args) throws Exception { int maxThreads = 100; - if (args.length > 0) + if (args.length > 0) maxThreads = Integer.parseInt(args[0]); print = true; @@ -48,15 +48,15 @@ public final class SimpleWriteLockLoops } final void test() throws Exception { - for (int i = 0; i < nthreads; ++i) + for (int i = 0; i < nthreads; ++i) pool.execute(this); barrier.await(); 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"); } @@ -68,7 +68,7 @@ public final class SimpleWriteLockLoops public final void run() { final Lock lock = this.lock.writeLock(); try { - barrier.await(); + barrier.await(); int sum = v + 1; int x = 0; int n = iters; @@ -87,12 +87,12 @@ public final class SimpleWriteLockLoops ++readBarrier; for (int l = x & 7; l > 0; --l) sum += LoopHelpers.compute6(sum); - } + } barrier.await(); result += sum; } - catch (Exception ie) { - return; + catch (Exception ie) { + return; } } }