@@ -0,0 +1,1182 @@
+package com.winterbe.java8.samples.concurrent;%0A%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.atomic.LongAdder;%0Aimport java.util.stream.IntStream;%0A%0A/**%0A * @author Benjamin Winterberg%0A */%0Apublic class LongAdder1 %7B%0A%0A    private static final int NUM_INCREMENTS = 10000;%0A%0A    private static LongAdder adder = new LongAdder();%0A%0A    public static void main(String%5B%5D args) %7B%0A        testIncrement();%0A        testAdd();%0A    %7D%0A%0A    private static void testAdd() %7B%0A        ExecutorService executor = Executors.newFixedThreadPool(2);%0A%0A        IntStream.range(0, NUM_INCREMENTS)%0A                .forEach(i -%3E executor.submit(() -%3E adder.add(2)));%0A%0A        ConcurrentUtils.stop(executor);%0A%0A        System.out.format(%22Add: %25d%5Cn%22, adder.sumThenReset());%0A    %7D%0A%0A    private static void testIncrement() %7B%0A        ExecutorService executor = Executors.newFixedThreadPool(2);%0A%0A        IntStream.range(0, NUM_INCREMENTS)%0A                .forEach(i -%3E executor.submit(adder::increment));%0A%0A        ConcurrentUtils.stop(executor);%0A%0A        System.out.format(%22Increment: Expected=%25d; Is=%25d%5Cn%22, NUM_INCREMENTS, adder.sumThenReset());%0A    %7D%0A%7D%0A

Add LongAdder example