--- jsr166/src/test/loops/CancelledLockLoops.java 2007/02/19 00:46:06 1.2 +++ jsr166/src/test/loops/CancelledLockLoops.java 2009/11/02 23:42:46 1.5 @@ -12,11 +12,11 @@ public final class CancelledLockLoops { static final Random rng = new Random(); static boolean print = false; static final int ITERS = 10000000; - static final long TIMEOUT = 100; + static final long TIMEOUT = 100; 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; @@ -26,7 +26,7 @@ public final class CancelledLockLoops { try { new ReentrantLockLoop(i).test(); } - catch(BrokenBarrierException bb) { + catch (BrokenBarrierException bb) { // OK, ignore } } @@ -47,9 +47,9 @@ public final class CancelledLockLoops { final void test() throws Exception { Thread[] threads = new Thread[nthreads]; - for (int i = 0; i < threads.length; ++i) + for (int i = 0; i < threads.length; ++i) threads[i] = new Thread(this); - for (int i = 0; i < threads.length; ++i) + for (int i = 0; i < threads.length; ++i) threads[i].start(); Thread[] cancels = (Thread[]) (threads.clone()); Collections.shuffle(Arrays.asList(cancels), rng); @@ -58,7 +58,7 @@ public final class CancelledLockLoops { for (int i = 0; i < cancels.length-2; ++i) { cancels[i].interrupt(); // make sure all OK even when cancellations spaced out - if ( (i & 3) == 0) + if ( (i & 3) == 0) Thread.sleep(1 + rng.nextInt(10)); } barrier.await(); @@ -76,7 +76,7 @@ public final class CancelledLockLoops { finally { lock.unlock(); } - if (completed != 2) + if (c != 2) throw new Error("Completed != 2"); int r = result; if (r == 0) // avoid overoptimization @@ -85,7 +85,7 @@ public final class CancelledLockLoops { public final void run() { try { - barrier.await(); + barrier.await(); int sum = v; int x = 0; int n = ITERS; @@ -106,7 +106,7 @@ public final class CancelledLockLoops { sum += LoopHelpers.compute2(x); } while (n-- > 0); if (n <= 0) { - lock.lock(); + lock.lock(); try { ++completed; } @@ -117,9 +117,9 @@ public final class CancelledLockLoops { barrier.await(); result += sum; } - catch (Exception ex) { + catch (Exception ex) { // ex.printStackTrace(); - return; + return; } } }