--- jsr166/src/test/loops/ConcurrentDequeLoops.java 2011/03/15 19:47:05 1.8 +++ jsr166/src/test/loops/ConcurrentDequeLoops.java 2016/10/23 03:03:23 1.13 @@ -18,7 +18,7 @@ public class ConcurrentDequeLoops { int maxStages = 8; int items = 1000000; - Class klass = null; + Class klass = null; if (args.length > 0) { try { klass = Class.forName(args[0]); @@ -43,8 +43,7 @@ public class ConcurrentDequeLoops { Thread.sleep(100); print = true; - int k = 1; - for (int i = 1; i <= maxStages;) { + for (int k = 1, i = 1; i <= maxStages;) { oneRun(klass, i, items); if (i == k) { k = i << 1; @@ -54,7 +53,7 @@ public class ConcurrentDequeLoops { i = k; } pool.shutdown(); - } + } static class Stage implements Callable { final Deque queue; @@ -117,8 +116,9 @@ public class ConcurrentDequeLoops { } } - static void oneRun(Class klass, int n, int items) throws Exception { - Deque q = (Deque) klass.newInstance(); + static void oneRun(Class klass, int n, int items) throws Exception { + Deque q = + (Deque) klass.getConstructor().newInstance(); LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); CyclicBarrier barrier = new CyclicBarrier(n + 1, timer); totalItems = new AtomicInteger(n * items); @@ -141,6 +141,5 @@ public class ConcurrentDequeLoops { System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item"); if (total == 0) // avoid overoptimization System.out.println("useless result: " + total); - } }