--- jsr166/src/test/loops/NQueensCS.java 2009/11/03 01:04:02 1.4 +++ jsr166/src/test/loops/NQueensCS.java 2015/09/12 19:53:04 1.9 @@ -1,7 +1,7 @@ /* * 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 jsr166y.*; @@ -19,7 +19,7 @@ public final class NQueensCS extends Rec }; // see http://www.durangobill.com/N_Queens.html static final int FIRST_SIZE = 8; // smaller ones too short to measure well - static final int LAST_SIZE = 15; // bigger ones too long to wait for + static final int LAST_SIZE = 16; // bigger ones too long to wait for /** for time conversion */ static final long NPS = (1000L * 1000 * 1000); @@ -35,14 +35,15 @@ public final class NQueensCS extends Rec return; } for (int reps = 0; reps < 2; ++reps) { - ForkJoinPool g = (procs == 0) ? - new ForkJoinPool() : + ForkJoinPool g = (procs == 0) ? ForkJoinPool.commonPool() : new ForkJoinPool(procs); lastStealCount = g.getStealCount(); for (int i = FIRST_SIZE; i <= LAST_SIZE; i++) test(g, i); System.out.println(g); - g.shutdown(); + if (g != ForkJoinPool.commonPool()) + g.shutdown(); + Thread.sleep(100); } } @@ -54,7 +55,7 @@ public final class NQueensCS extends Rec g.invoke(task); int solutions = task.solutions; long time = System.nanoTime() - start; - double secs = (double) time / NPS; + double secs = ((double)time) / NPS; if (solutions != expectedSolutions[i]) throw new Error(); System.out.printf("NQueensCS %3d", i); @@ -112,12 +113,14 @@ public final class NQueensCS extends Rec s.compute(); int ns = s.solutions; s = s.nextSubtask; + /* comment out to stress join // Then the unstolen ones while (s != null && s.tryUnfork()) { s.compute(); ns += s.solutions; s = s.nextSubtask; } + */ // Then wait for the stolen ones while (s != null) { s.join();