--- jsr166/src/test/loops/ExecutorCompletionServiceLoops.java 2005/05/02 19:19:38 1.1 +++ jsr166/src/test/loops/ExecutorCompletionServiceLoops.java 2011/03/15 19:47:05 1.4 @@ -1,23 +1,16 @@ /* - * @test %I% %E% - * @bug 166 - * @compile -source 1.5 ExecutorCompletionServiceLoops.java - * @run main/timeout=3600 ExecutorCompletionServiceLoops - * @summary Exercise ExecutorCompletionServiceLoops - */ -/* * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain. Use, modify, and - * redistribute this code in any way without acknowledgement. + * Expert Group and released to the public domain, as explained at + * http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.concurrent.*; public class ExecutorCompletionServiceLoops { static final int POOLSIZE = 100; - static final ExecutorService pool = + static final ExecutorService pool = Executors.newFixedThreadPool(POOLSIZE); - static final ExecutorCompletionService ecs = + static final ExecutorCompletionService ecs = new ExecutorCompletionService(pool); static boolean print = false; @@ -25,14 +18,14 @@ public class ExecutorCompletionServiceLo int max = 8; int base = 10000; - if (args.length > 0) + if (args.length > 0) max = Integer.parseInt(args[0]); System.out.println("Warmup..."); oneTest( base ); Thread.sleep(100); print = true; - + for (int i = 1; i <= max; i += (i+1) >>> 1) { System.out.print("n: " + i * base); oneTest(i * base ); @@ -40,7 +33,7 @@ public class ExecutorCompletionServiceLo } pool.shutdown(); } - + static class Task implements Callable { public Integer call() { int l = System.identityHashCode(this); @@ -55,9 +48,9 @@ public class ExecutorCompletionServiceLo static class Producer implements Runnable { final ExecutorCompletionService cs; final int iters; - Producer(ExecutorCompletionService ecs, int i) { + Producer(ExecutorCompletionService ecs, int i) { cs = ecs; - iters = i; + iters = i; } public void run() { for (int i = 0; i < iters; ++i)