21 |
|
return; |
22 |
|
} |
23 |
|
for (int reps = 0; reps < 2; ++reps) { |
24 |
< |
ForkJoinPool pool = procs == 0? new ForkJoinPool() : |
24 |
> |
ForkJoinPool pool = procs == 0? new ForkJoinPool() : |
25 |
|
new ForkJoinPool(procs); |
26 |
< |
for (int i = 0; i < 20; ++i) |
26 |
> |
for (int i = 0; i < 20; ++i) |
27 |
|
test(pool, num); |
28 |
|
System.out.println(pool); |
29 |
|
pool.shutdown(); |
51 |
|
|
52 |
|
int number; // Initialized with argument; replaced with result |
53 |
|
DynamicFib(int n) { number = n; } |
54 |
< |
public void compute() { |
55 |
< |
number = fib(number); |
54 |
> |
public void compute() { |
55 |
> |
number = fib(number); |
56 |
|
} |
57 |
|
|
58 |
|
static int fib(int n) { |
59 |
|
int res; |
60 |
< |
if (n <= 1) |
60 |
> |
if (n <= 1) |
61 |
|
res = n; |
62 |
|
else if (getSurplusQueuedTaskCount() >= 4) |
63 |
|
res = seqFib(n); |