--- jsr166/src/test/loops/CheckedLockLoops.java 2009/11/02 23:42:46 1.5 +++ jsr166/src/test/loops/CheckedLockLoops.java 2014/12/18 18:13:06 1.9 @@ -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/ */ /* * @test @@ -31,8 +31,7 @@ public final class CheckedLockLoops { static void runTest(int maxThreads, int iters) throws Exception { print = true; - int k = 1; - for (int i = 1; i <= maxThreads;) { + for (int k = 1, i = 1; i <= maxThreads;) { System.out.println("Threads:" + i); oneTest(i, iters / i); if (i == k) { @@ -118,7 +117,7 @@ public final class CheckedLockLoops { Thread.sleep(10); } - static abstract class LockLoop implements Runnable { + abstract static class LockLoop implements Runnable { int value; int checkValue; int iters; @@ -197,7 +196,7 @@ public final class CheckedLockLoops { int sum = 0; int x = 0; while (n-- > 0) { - synchronized(this) { + synchronized (this) { x = setValue(LoopHelpers.compute1(getValue())); } sum += LoopHelpers.compute2(x); @@ -207,7 +206,7 @@ public final class CheckedLockLoops { } private static class ReentrantLockLoop extends LockLoop { - final private ReentrantLock lock = new ReentrantLock(); + private final ReentrantLock lock = new ReentrantLock(); final int loop(int n) { final ReentrantLock lock = this.lock; int sum = 0; @@ -227,7 +226,7 @@ public final class CheckedLockLoops { } private static class MutexLoop extends LockLoop { - final private Mutex lock = new Mutex(); + private final Mutex lock = new Mutex(); final int loop(int n) { final Mutex lock = this.lock; int sum = 0; @@ -247,7 +246,7 @@ public final class CheckedLockLoops { } private static class LongMutexLoop extends LockLoop { - final private LongMutex lock = new LongMutex(); + private final LongMutex lock = new LongMutex(); final int loop(int n) { final LongMutex lock = this.lock; int sum = 0; @@ -267,7 +266,7 @@ public final class CheckedLockLoops { } 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) { final ReentrantLock lock = this.lock; int sum = 0; @@ -287,7 +286,7 @@ public final class CheckedLockLoops { } 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) { final Lock lock = this.lock; int sum = 0; @@ -327,7 +326,7 @@ public final class CheckedLockLoops { } 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) { final Semaphore sem = this.sem; int sum = 0; @@ -346,7 +345,7 @@ public final class CheckedLockLoops { } } 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) { final Semaphore sem = this.sem; int sum = 0; @@ -366,7 +365,7 @@ public final class CheckedLockLoops { } private static class ReentrantReadWriteLockLoop extends LockLoop { - final private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); final int loop(int n) { final Lock rlock = lock.readLock(); final Lock wlock = lock.writeLock(); @@ -401,7 +400,7 @@ public final class CheckedLockLoops { 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) { final Lock rlock = lock.readLock(); final Lock wlock = lock.writeLock();