--- jsr166/src/test/loops/BoxedLongSort.java 2010/09/19 12:55:36 1.1 +++ jsr166/src/test/loops/BoxedLongSort.java 2011/10/10 16:59:04 1.6 @@ -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 java.util.concurrent.*; @@ -13,7 +13,7 @@ class BoxedLongSort { static int THRESHOLD; static final boolean warmup = true; - public static void main (String[] args) throws Exception { + public static void main(String[] args) throws Exception { int procs = 0; int n = 1 << 22; int reps = 20; @@ -30,9 +30,9 @@ class BoxedLongSort { System.out.println("Usage: java BoxedLongSort threads n reps"); return; } - ForkJoinPool pool = procs == 0? new ForkJoinPool() : + ForkJoinPool pool = (procs == 0) ? new ForkJoinPool() : new ForkJoinPool(procs); - + Long[] a = new Long[n]; seqRandomFill(a, 0, n); @@ -80,15 +80,15 @@ class BoxedLongSort { } static final class Sorter extends RecursiveAction { - final Long[] a; + final Long[] a; final Long[] w; - final int origin; + final int origin; final int n; Sorter(Long[] a, Long[] w, int origin, int n) { this.a = a; this.w = w; this.origin = origin; this.n = n; } - public void compute() { + public void compute() { int l = origin; if (n <= THRESHOLD) Arrays.sort(a, l, l+n); @@ -111,7 +111,7 @@ class BoxedLongSort { } } } - + static final class SubSorter extends RecursiveAction { final Sorter left; final Sorter right; @@ -145,7 +145,7 @@ class BoxedLongSort { * and finding index of right closest to split point. * Uses left-spine decomposition to generate all * merge tasks before bottomming out at base case. - * + * */ public final void compute() { Merger rights = null; @@ -169,11 +169,11 @@ class BoxedLongSort { nleft = lh; nright = rh; } - + merge(nleft, nright); - if (rights != null) + if (rights != null) collectRights(rights); - + } final void merge(int nleft, int nright) { @@ -206,11 +206,11 @@ class BoxedLongSort { } - static void checkSorted (Long[] a) { + static void checkSorted(Long[] a) { int n = a.length; for (int i = 0; i < n - 1; i++) { if (a[i] > a[i+1]) { - throw new Error("Unsorted at " + i + ": " + + throw new Error("Unsorted at " + i + ": " + a[i] + " / " + a[i+1]); } }