--- jsr166/src/test/loops/TimeoutLockLoops.java 2005/05/02 19:19:38 1.1 +++ jsr166/src/test/loops/TimeoutLockLoops.java 2014/12/31 17:00:58 1.8 @@ -1,7 +1,11 @@ /* - * @test %I% %E% + * 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/publicdomain/zero/1.0/ + */ +/* + * @test * @bug 4486658 - * @compile -source 1.5 TimeoutLockLoops.java * @run main TimeoutLockLoops * @summary Checks for responsiveness of locks to timeouts. * Runs under the assumption that ITERS computations require more than @@ -9,20 +13,20 @@ * another decade. */ +import java.util.*; import java.util.concurrent.*; import java.util.concurrent.locks.*; -import java.util.*; public final class TimeoutLockLoops { static final ExecutorService pool = Executors.newCachedThreadPool(); static final LoopHelpers.SimpleRandom rng = new LoopHelpers.SimpleRandom(); static boolean print = false; static final int ITERS = Integer.MAX_VALUE; - 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; @@ -61,7 +65,7 @@ public final class TimeoutLockLoops { barrier.await(); if (print) { long time = timer.getTime(); - double secs = (double)(time) / 1000000000.0; + double secs = (double) time / 1000000000.0; System.out.println("\t " + secs + "s run time"); } @@ -74,7 +78,7 @@ public final class TimeoutLockLoops { public final void run() { try { - barrier.await(); + barrier.await(); int sum = v; int x = 17; int n = ITERS; @@ -99,9 +103,9 @@ public final class TimeoutLockLoops { barrier.await(); result += sum; } - catch (Exception ex) { + catch (Exception ex) { ex.printStackTrace(); - return; + return; } } }