shutdown the pool
@@ -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);
+
+ try {
long actualTotal = customThreadPool
- .submit(() -> aList.parallelStream()
- .reduce(0L, Long::sum))
+ .submit(() -> aList.parallelStream().reduce(0L, Long::sum))
.get();
-
assertEquals((lastNum + firstNum) * lastNum / 2, actualTotal);
+ } finally {
+ customThreadPool.shutdown();
+ }
}
@Test
