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