4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
– |
import java.util.*; |
7 |
|
import java.util.concurrent.atomic.LongAdder; |
8 |
|
import java.util.concurrent.Executors; |
9 |
|
import java.util.concurrent.ExecutorService; |
10 |
|
import java.util.concurrent.Phaser; |
11 |
|
|
12 |
|
public class LongAdderLoops { |
13 |
< |
static final int ITERS = 10000000; |
13 |
> |
static final int ITERS = 100_000_000; |
14 |
|
static final int NCPU = Runtime.getRuntime().availableProcessors(); |
15 |
|
static final int MAX_THREADS = NCPU * 2; |
17 |
– |
static final long NPS = (1000L * 1000 * 1000); |
16 |
|
|
17 |
|
static final ExecutorService pool = Executors.newCachedThreadPool(); |
18 |
|
|
54 |
|
final Phaser phaser; |
55 |
|
final int incs; |
56 |
|
volatile long result; |
57 |
< |
AdderTask(LongAdder adder, Phaser phaser, int incs) { |
58 |
< |
this.adder = adder; |
57 |
> |
AdderTask(LongAdder adder, Phaser phaser, int incs) { |
58 |
> |
this.adder = adder; |
59 |
|
this.phaser = phaser; |
60 |
|
this.incs = incs; |
61 |
|
} |