Skip to content

Commit d3dda84

Browse files
committed
Cosmetics
1 parent 01dfc04 commit d3dda84

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/com/winterbe/java8/samples/concurrent/Atomic1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
public class Atomic1 {
1313

14-
private static final int NUM_INCREMENTS = 10000;
14+
private static final int NUM_INCREMENTS = 1000;
1515

1616
private static AtomicInteger atomicInt = new AtomicInteger(0);
1717

src/com/winterbe/java8/samples/concurrent/LongAccumulator1.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
import java.util.concurrent.ExecutorService;
44
import java.util.concurrent.Executors;
55
import java.util.concurrent.atomic.LongAccumulator;
6+
import java.util.function.LongBinaryOperator;
67
import java.util.stream.IntStream;
78

89
/**
910
* @author Benjamin Winterberg
1011
*/
1112
public class LongAccumulator1 {
1213

13-
private static final int SIZE = 10;
14-
15-
private static LongAccumulator accumulator = new LongAccumulator((x, y) -> 2 * x + y, 1L);
16-
1714
public static void main(String[] args) {
1815
testAccumulate();
1916
}
2017

2118
private static void testAccumulate() {
19+
LongBinaryOperator op = (x, y) -> 2 * x + y;
20+
LongAccumulator accumulator = new LongAccumulator(op, 1L);
21+
2222
ExecutorService executor = Executors.newFixedThreadPool(2);
2323

24-
IntStream.range(0, SIZE)
24+
IntStream.range(0, 10)
2525
.forEach(i -> executor.submit(() -> accumulator.accumulate(i)));
2626

2727
ConcurrentUtils.stop(executor);

0 commit comments

Comments
 (0)