question: public void testAddAndSumMT ( ) throws Throwable { final int incs = 1000000 ; final int nthreads = 4 ; final ExecutorService pool = Executors . newCachedThreadPool ( ) ; LongAdder a = new LongAdder ( ) ; CyclicBarrier barrier = new CyclicBarrier ( nthreads + 1 ) ; for ( int i = 0 ; i < nthreads ; ++ i ) pool . execute ( new AdderTask ( a , barrier , incs ) ) ; barrier . await ( ) ; barrier . await ( ) ; long total = ( long ) nthreads * incs ; long sum = a . sum ( ) ; assertEquals ( sum , total ) ; pool . shutdown ( ) ; }
target:  adds by multiple threads produce correct sum