commit
74aebe1a62
|
@ -21,14 +21,16 @@ public class ThreadPoolInParallelStreamIntegrationTest {
|
|||
long lastNum = 1_000_000;
|
||||
|
||||
List<Long> aList = LongStream.rangeClosed(firstNum, lastNum).boxed().collect(Collectors.toList());
|
||||
|
||||
ForkJoinPool customThreadPool = new ForkJoinPool(4);
|
||||
long actualTotal = customThreadPool
|
||||
.submit(() -> aList.parallelStream()
|
||||
.reduce(0L, Long::sum))
|
||||
.get();
|
||||
|
||||
assertEquals((lastNum + firstNum) * lastNum / 2, actualTotal);
|
||||
try {
|
||||
long actualTotal = customThreadPool
|
||||
.submit(() -> aList.parallelStream().reduce(0L, Long::sum))
|
||||
.get();
|
||||
assertEquals((lastNum + firstNum) * lastNum / 2, actualTotal);
|
||||
} finally {
|
||||
customThreadPool.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue