ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166y/RecursiveTask.java
(Generate patch)

Comparing jsr166/src/jsr166y/RecursiveTask.java (file contents):
Revision 1.2 by jsr166, Mon Jul 20 21:45:06 2009 UTC vs.
Revision 1.10 by jsr166, Sat Aug 1 21:17:11 2009 UTC

# Line 7 | Line 7
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 < * <pre>
13 < * class Fibonacci extends RecursiveTask&lt;Integer&gt; {
12 > * <p>For a classic example, here is a task computing Fibonacci numbers:
13 > *
14 > *  <pre> {@code
15 > * class Fibonacci extends RecursiveTask<Integer> {
16   *   final int n;
17 < *   Fibonnaci(int n) { this.n = n; }
17 > *   Fibonacci(int n) { this.n = n; }
18   *   Integer compute() {
19 < *     if (n &lt;= 1)
19 > *     if (n <= 1)
20   *        return n;
21   *     Fibonacci f1 = new Fibonacci(n - 1);
22   *     f1.fork();
23   *     Fibonacci f2 = new Fibonacci(n - 2);
24   *     return f2.compute() + f1.join();
25   *   }
26 < * }
26 < * </pre>
26 > * }}</pre>
27   *
28   * However, besides being a dumb way to compute Fibonacci functions
29   * (there is a simple fast linear algorithm that you'd use in
# Line 33 | Line 33 | package jsr166y;
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 contructor for use by subclasses.
41 <     */
42 <    protected RecursiveTask() {
43 <    }
44 <
45 <    /**
46 <     * The result returned by compute method.
43 >     * The result of the computation.
44       */
45      V result;
46  
# Line 61 | Line 58 | public abstract class RecursiveTask<V> e
58      }
59  
60      /**
61 <     * Implements execution conventions for RecursiveTask
61 >     * Implements execution conventions for RecursiveTask.
62       */
63      protected final boolean exec() {
64          result = compute();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines