question: public void testAccumulateAndGetMT ( ) { final int incs = 1000000 ; final int nthreads = 4 ; final ExecutorService pool = Executors . newCachedThreadPool ( ) ; LongAccumulator a = new LongAccumulator ( null , 0L ) ; Phaser phaser = new Phaser ( nthreads + 1 ) ; for ( int i = 0 ; i < nthreads ; ++ i ) pool . execute ( new AccTask ( a , phaser , incs ) ) ; phaser . arriveAndAwaitAdvance ( ) ; phaser . arriveAndAwaitAdvance ( ) ; long expected = incs - 1 ; long result = a . get ( ) ; assertEquals ( expected , result ) ; pool . shutdown ( ) ; }
target:  accumulates by multiple threads produce correct result