--- jsr166/src/test/loops/ContextSwitchTest.java 2005/09/15 16:55:40 1.3 +++ jsr166/src/test/loops/ContextSwitchTest.java 2014/12/31 17:00:58 1.7 @@ -1,16 +1,16 @@ /* * 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/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ +import java.util.*; import java.util.concurrent.*; -import java.util.concurrent.locks.*; import java.util.concurrent.atomic.*; -import java.util.*; +import java.util.concurrent.locks.*; public final class ContextSwitchTest { - final static int iters = 1000000; + static final int iters = 1000000; static AtomicReference turn = new AtomicReference(); public static void main(String[] args) throws Exception { test(); @@ -31,7 +31,7 @@ public final class ContextSwitchTest { b.join(); long endTime = System.nanoTime(); int np = a.nparks + b.nparks; - System.out.println("Average time: " + + System.out.println("Average time: " + ((endTime - startTime) / np) + "ns"); } @@ -43,7 +43,7 @@ public final class ContextSwitchTest { public void run() { final AtomicReference t = turn; final Thread other = this.other; - if (turn == null || other == null) + if (turn == null || other == null) throw new NullPointerException(); int p = 0; for (int i = 0; i < iters; ++i) { @@ -56,9 +56,7 @@ public final class ContextSwitchTest { LockSupport.unpark(other); nparks = p; System.out.println("parks: " + p); - + } } } - -