/** * Waits for and returns the results of the child tasks. * * @return A list of results returned from the child tasks */ public final List<T> getChildrenResults() { if (children == null) return Collections.emptyList(); final List<T> results = new ArrayList<T>(children.size()); for (final AbstractForkJoinWorker<T> worker : children) { results.add(worker.join()); } return results; }
/** * Forks a child task. Makes sure it has a means to indicate back completion. The worker is stored * in the internal list of workers for evidence and easy result retrieval through * getChildrenResults(). * * @param child The child task */ protected final void forkOffChild(final AbstractForkJoinWorker<T> child) { if (children == null) children = new ArrayList<AbstractForkJoinWorker<T>>(); children.add(child); child.fork(); }