--- jsr166/src/jsr166y/CountedCompleter.java 2012/10/21 05:22:35 1.4 +++ jsr166/src/jsr166y/CountedCompleter.java 2012/11/14 18:45:53 1.11 @@ -27,8 +27,8 @@ package jsr166y; * affect only internal counts; they do not establish any further * internal bookkeeping. In particular, the identities of pending * tasks are not maintained. As illustrated below, you can create - * subclasses that do record some or all pended tasks or their results - * when needed. + * subclasses that do record some or all pending tasks or their + * results when needed. * *

A concrete CountedCompleter class must define method {@link * #compute}, that should, in almost all use cases, invoke {@code @@ -142,7 +142,7 @@ package jsr166y; * * As a further improvement, notice that the left task need not even * exist. Instead of creating a new one, we can iterate using the - * original task, and add a pending count for each fork: + * original task, and add a pending count for each fork. * *

 {@code
  * class ForEach ...
@@ -378,6 +378,19 @@ public abstract class CountedCompleter getRoot() {
+        CountedCompleter a = this, p;
+        while ((p = a.completer) != null)
+            a = p;
+        return a;
+    }
+
+    /**
      * If the pending count is nonzero, decrements the count;
      * otherwise invokes {@link #onCompletion} and then similarly
      * tries to complete this task's completer, if one exists,
@@ -464,8 +477,6 @@ public abstract class CountedCompleter