Bael 856 long adder (#1748)
* BAEL-856 code for long adder and accumulator * BAEL-856 rearange packages * BAEL-856 Formatting * BAEL-850 accumulator accumulates values * BAEL-881 use Long::sum
This commit is contained in:
parent
01cad343f7
commit
9a3df1fe76
|
@ -17,9 +17,8 @@ public class LongAccumulatorTest {
|
|||
public void givenLongAccumulator_whenApplyActionOnItFromMultipleThrads_thenShouldProduceProperResult() throws InterruptedException {
|
||||
//given
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(8);
|
||||
LongBinaryOperator higherValueFinder = (currentValue, previousValue) -> currentValue > previousValue ? currentValue : previousValue;
|
||||
LongAccumulator accumulator = new LongAccumulator(higherValueFinder, 0L);
|
||||
|
||||
LongBinaryOperator sum = Long::sum;
|
||||
LongAccumulator accumulator = new LongAccumulator(sum, 0L);
|
||||
int numberOfThreads = 4;
|
||||
int numberOfIncrements = 100;
|
||||
|
||||
|
@ -32,10 +31,12 @@ public class LongAccumulatorTest {
|
|||
executorService.execute(accumulateAction);
|
||||
}
|
||||
|
||||
|
||||
//then
|
||||
executorService.awaitTermination(500, TimeUnit.MILLISECONDS);
|
||||
executorService.shutdown();
|
||||
assertEquals(accumulator.get(), 20200);
|
||||
|
||||
|
||||
assertEquals(accumulator.get(), 100);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue