13 |
|
* <pre> |
14 |
|
* class Fibonacci extends RecursiveTask<Integer> { |
15 |
|
* final int n; |
16 |
< |
* Fibonnaci(int n) { this.n = n; } |
16 |
> |
* Fibonacci(int n) { this.n = n; } |
17 |
|
* Integer compute() { |
18 |
|
* if (n <= 1) |
19 |
|
* return n; |
31 |
|
* subtasks are too small to be worthwhile splitting up. Instead, as |
32 |
|
* is the case for nearly all fork/join applications, you'd pick some |
33 |
|
* minimum granularity size (for example 10 here) for which you always |
34 |
< |
* sequentially solve rather than subdividing. |
34 |
> |
* sequentially solve rather than subdividing. |
35 |
|
* |
36 |
|
*/ |
37 |
|
public abstract class RecursiveTask<V> extends ForkJoinTask<V> { |
38 |
|
|
39 |
|
/** |
40 |
< |
* Empty contructor for use by subclasses. |
40 |
> |
* Empty constructor for use by subclasses. |
41 |
|
*/ |
42 |
|
protected RecursiveTask() { |
43 |
|
} |
48 |
|
V result; |
49 |
|
|
50 |
|
/** |
51 |
< |
* The main computation performed by this task. |
51 |
> |
* The main computation performed by this task. |
52 |
|
*/ |
53 |
|
protected abstract V compute(); |
54 |
|
|