Runs the subtasks and returns the results.
Submits the left task to the executor first, runs the right task in the current thread, and waits for them to complete.
This method uses the executor of the common task env.
int fibonacci (int n) {
if (n <= 1) {
return n;
} else {
// Note. Not 'int' but 'int?' (boxed value type)
var (left, right) = join<int?>( () => fibonacci(n-1),
() => fibonacci(n-2) );
return left + right;
}
}
left |
the left task |
right |
the right task |
(left-result, right-result) An array containing the two results. |
Error |
the error thrown by the subtasks |