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.3 by jsr166, Mon Jul 20 22:26:04 2009 UTC vs.
Revision 1.4 by jsr166, Mon Jul 20 22:40:09 2009 UTC

# Line 10 | Line 10 | package jsr166y;
10   * Recursive result-bearing ForkJoinTasks.
11   * <p> For a classic example, here is a task computing Fibonacci numbers:
12   *
13 < * <pre>
14 < * class Fibonacci extends RecursiveTask&lt;Integer&gt; {
13 > *  <pre> {@code
14 > * class Fibonacci extends RecursiveTask<Integer> {
15   *   final int n;
16   *   Fibonacci(int n) { this.n = n; }
17   *   Integer compute() {
18 < *     if (n &lt;= 1)
18 > *     if (n <= 1)
19   *        return n;
20   *     Fibonacci f1 = new Fibonacci(n - 1);
21   *     f1.fork();
22   *     Fibonacci f2 = new Fibonacci(n - 2);
23   *     return f2.compute() + f1.join();
24   *   }
25 < * }
26 < * </pre>
25 > * }}</pre>
26   *
27   * However, besides being a dumb way to compute Fibonacci functions
28   * (there is a simple fast linear algorithm that you'd use in

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines