7 |
|
package jsr166y; |
8 |
|
|
9 |
|
/** |
10 |
< |
* Recursive result-bearing ForkJoinTasks. |
11 |
< |
* <p> For a classic example, here is a task computing Fibonacci numbers: |
10 |
> |
* A recursive result-bearing {@link ForkJoinTask}. |
11 |
> |
* |
12 |
> |
* <p>For a classic example, here is a task computing Fibonacci numbers: |
13 |
|
* |
14 |
|
* <pre> {@code |
15 |
|
* class Fibonacci extends RecursiveTask<Integer> { |
33 |
|
* minimum granularity size (for example 10 here) for which you always |
34 |
|
* sequentially solve rather than subdividing. |
35 |
|
* |
36 |
+ |
* @since 1.7 |
37 |
+ |
* @author Doug Lea |
38 |
|
*/ |
39 |
|
public abstract class RecursiveTask<V> extends ForkJoinTask<V> { |
40 |
+ |
private static final long serialVersionUID = 5232453952276485270L; |
41 |
|
|
42 |
|
/** |
43 |
< |
* Empty constructor for use by subclasses. |
40 |
< |
*/ |
41 |
< |
protected RecursiveTask() { |
42 |
< |
} |
43 |
< |
|
44 |
< |
/** |
45 |
< |
* The result returned by compute method. |
43 |
> |
* The result of the computation. |
44 |
|
*/ |
45 |
|
V result; |
46 |
|
|
58 |
|
} |
59 |
|
|
60 |
|
/** |
61 |
< |
* Implements execution conventions for RecursiveTask |
61 |
> |
* Implements execution conventions for RecursiveTask. |
62 |
|
*/ |
63 |
|
protected final boolean exec() { |
64 |
|
result = compute(); |