--- jsr166/src/test/loops/LockLoops.java 2005/05/09 19:33:30 1.2 +++ jsr166/src/test/loops/LockLoops.java 2011/03/15 19:47:05 1.7 @@ -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/ */ /* * A simple test program. Feel free to play. @@ -25,13 +25,13 @@ public final class LockLoops { int iters = 1000000; int replications = 1; - if (args.length > 0) + if (args.length > 0) maxThreads = Integer.parseInt(args[0]); - if (args.length > 1) + if (args.length > 1) iters = Integer.parseInt(args[1]); - if (args.length > 2) + if (args.length > 2) replications = Integer.parseInt(args[2]); rng.setSeed(3122688L); @@ -131,7 +131,7 @@ public final class LockLoops { } - static abstract class LockLoop implements Runnable { + abstract static class LockLoop implements Runnable { int v; int iters; volatile int result; @@ -142,7 +142,7 @@ public final class LockLoops { v = initialValue; this.iters = iters; barrier = new CyclicBarrier(nthreads+1, timer); - for (int i = 0; i < nthreads; ++i) + for (int i = 0; i < nthreads; ++i) pool.execute(this); barrier.await(); barrier.await(); @@ -150,7 +150,7 @@ public final class LockLoops { if (print) { long tpi = time / (iters * nthreads); System.out.print("\t" + LoopHelpers.rightJustify(tpi) + " ns per update"); - // double secs = (double)(time) / 1000000000.0; + // double secs = (double) time / 1000000000.0; // System.out.print("\t " + secs + "s run time"); System.out.println(); } @@ -161,12 +161,12 @@ public final class LockLoops { abstract int loop(int n); public final void run() { try { - barrier.await(); + barrier.await(); result += loop(iters); barrier.await(); } - catch (Exception ie) { - return; + catch (Exception ie) { + return; } } @@ -176,7 +176,7 @@ public final class LockLoops { final int loop(int n) { int sum = 0; while (n-- > 0) { - synchronized(this) { + synchronized (this) { v = LoopHelpers.compute1(v); } sum += LoopHelpers.compute2(v); @@ -198,7 +198,7 @@ public final class LockLoops { } private static class NoLockVolatileLoop extends LockLoop { - volatile private int vv; + private volatile int vv; final int loop(int n) { int sum = 0; while (n-- > 0) { @@ -211,7 +211,7 @@ public final class LockLoops { } private static class ReentrantLockLoop extends LockLoop { - final private ReentrantLock lock = new ReentrantLock(); + private final ReentrantLock lock = new ReentrantLock(); final int loop(int n) { int sum = 0; while (n-- > 0) { @@ -229,7 +229,7 @@ public final class LockLoops { } private static class FairReentrantLockLoop extends LockLoop { - final private ReentrantLock lock = new ReentrantLock(true); + private final ReentrantLock lock = new ReentrantLock(true); final int loop(int n) { int sum = 0; while (n-- > 0) { @@ -247,7 +247,7 @@ public final class LockLoops { } private static class ReentrantWriteLockLoop extends LockLoop { - final private Lock lock = new ReentrantReadWriteLock().writeLock(); + private final Lock lock = new ReentrantReadWriteLock().writeLock(); final int loop(int n) { int sum = 0; while (n-- > 0) { @@ -265,7 +265,7 @@ public final class LockLoops { } private static class ReentrantReadWriteLockLoop extends LockLoop { - final private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); final int loop(int n) { int sum = 0; while (n-- > 0) { @@ -309,7 +309,7 @@ public final class LockLoops { } private static class SemaphoreLoop extends LockLoop { - final private Semaphore sem = new Semaphore(1, false); + private final Semaphore sem = new Semaphore(1, false); final int loop(int n) { int sum = 0; try { @@ -331,7 +331,7 @@ public final class LockLoops { } } private static class FairSemaphoreLoop extends LockLoop { - final private Semaphore sem = new Semaphore(1, true); + private final Semaphore sem = new Semaphore(1, true); final int loop(int n) { int sum = 0; try { @@ -354,7 +354,7 @@ public final class LockLoops { } private static class FairReentrantReadWriteLockLoop extends LockLoop { - final private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); final int loop(int n) { int sum = 0; while (n-- > 0) {