--- jsr166/src/test/loops/ExchangeLoops.java 2006/04/19 15:10:47 1.3 +++ jsr166/src/test/loops/ExchangeLoops.java 2010/09/01 07:20:36 1.7 @@ -1,8 +1,7 @@ /* * Written by Bill Scherer and 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. + * of JCP JSR-166 Expert Group and released to the public domain, as + * explained at http://creativecommons.org/licenses/publicdomain */ import java.util.concurrent.*; @@ -28,20 +27,20 @@ public class ExchangeLoops { trialMillis = Integer.parseInt(args[argc]); else if (option.equals("-r")) nReps = Integer.parseInt(args[argc]); - else + else maxThreads = Integer.parseInt(option); argc++; } - // Display runtime parameters - System.out.print("ExchangeTest"); - System.out.print(" -t " + trialMillis); + // Display runtime parameters + System.out.print("ExchangeTest"); + System.out.print(" -t " + trialMillis); System.out.print(" -r " + nReps); - System.out.print(" max threads " + maxThreads); - System.out.println(); + System.out.print(" max threads " + maxThreads); + System.out.println(); long warmupTime = 2000; long sleepTime = 100; - int nw = maxThreads >= 3? 3 : 2; + int nw = (maxThreads >= 3) ? 3 : 2; System.out.println("Warmups.."); oneRun(3, warmupTime); @@ -97,10 +96,10 @@ public class ExchangeLoops { threads[i].start(); } Thread.sleep(trialMillis); - for (int i = 0; i < nThreads; ++i) + for (int i = 0; i < nThreads; ++i) threads[i].interrupt(); long elapsed = System.nanoTime() - startTime; - for (int i = 0; i < nThreads; ++i) + for (int i = 0; i < nThreads; ++i) threads[i].join(); int iters = 1; // System.out.println(); @@ -117,7 +116,7 @@ public class ExchangeLoops { System.out.println(); // x.printStats(); } - + static final class Runner implements Runnable { final Exchanger exchanger; final Object mine = new Integer(2688); @@ -142,4 +141,3 @@ public class ExchangeLoops { } } } -