1 |
< |
import java.util.concurrent.*; |
1 |
> |
/* |
2 |
> |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
> |
* Expert Group and released to the public domain, as explained at |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
> |
*/ |
6 |
> |
|
7 |
|
import java.util.*; |
8 |
< |
import java.util.concurrent.TimeUnit; |
4 |
< |
//import java.util.concurrent.*; |
8 |
> |
import java.util.concurrent.*; |
9 |
|
|
10 |
|
public final class DynamicLeftSpineFib extends RecursiveAction { |
11 |
|
|
12 |
|
static long lastStealCount; |
13 |
< |
|
13 |
> |
|
14 |
|
public static void main(String[] args) throws Exception { |
15 |
|
int procs = 0; |
16 |
|
int num = 45; |
25 |
|
return; |
26 |
|
} |
27 |
|
|
28 |
< |
|
28 |
> |
|
29 |
|
for (int reps = 0; reps < 2; ++reps) { |
30 |
< |
ForkJoinPool g = procs == 0? new ForkJoinPool() : |
30 |
> |
ForkJoinPool g = (procs == 0) ? new ForkJoinPool() : |
31 |
|
new ForkJoinPool(procs); |
32 |
|
lastStealCount = g.getStealCount(); |
33 |
|
for (int i = 0; i < 20; ++i) { |
64 |
|
int number; |
65 |
|
DynamicLeftSpineFib next; |
66 |
|
|
67 |
< |
DynamicLeftSpineFib(int n, DynamicLeftSpineFib nxt) { |
68 |
< |
number = n; next = nxt; |
67 |
> |
DynamicLeftSpineFib(int n, DynamicLeftSpineFib nxt) { |
68 |
> |
number = n; next = nxt; |
69 |
|
} |
70 |
|
|
71 |
|
int getAnswer() { |
72 |
|
return number; |
73 |
|
} |
74 |
< |
public void compute() { |
75 |
< |
number = fib(number); |
74 |
> |
public void compute() { |
75 |
> |
number = fib(number); |
76 |
|
} |
77 |
|
|
78 |
|
static final int fib(int n) { |
101 |
|
r += collectRights(rt); |
102 |
|
return r; |
103 |
|
} |
104 |
< |
|
104 |
> |
|
105 |
|
static final int collectRights(DynamicLeftSpineFib rt) { |
106 |
|
int r = 0; |
107 |
|
while (rt != null) { |
129 |
|
} |
130 |
|
|
131 |
|
} |
128 |
– |
|