5 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
6 |
|
*/ |
7 |
|
|
8 |
– |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
9 |
– |
import static java.util.concurrent.TimeUnit.SECONDS; |
10 |
– |
|
8 |
|
import java.util.concurrent.CountedCompleter; |
9 |
|
import java.util.concurrent.ThreadLocalRandom; |
10 |
|
import java.util.concurrent.atomic.AtomicInteger; |
120 |
|
Integer[] a = new Integer[n]; |
121 |
|
for (int i = 0; i < n; i++) a[i] = i + 1; |
122 |
|
AtomicInteger ai = new AtomicInteger(0); |
123 |
< |
action.accept(a, (x) -> ai.addAndGet(x)); |
123 |
> |
action.accept(a, ai::addAndGet); |
124 |
|
assertEquals(n * (n + 1) / 2, ai.get()); |
125 |
|
} |
126 |
|
|