Custom Thread Pools In Java 8 Parallel Streams (#1088)

* String to char array and char array to String.

* Method change

* Custom ThreadPool In Java 8 Parallel Streams

* Implemented suggested edits from editor.

* Broke long method signature

* Changed primitive type int to long and formula.

* Update wrapper type to Long
This commit is contained in:
Dotun Kola-Olaleye 2017-02-02 18:30:05 +01:00 committed by adamd1985
parent c350e8b423
commit a1312e9ce0

View File

@ -17,11 +17,11 @@ public class ThreadPoolInParallelStream {
@Test @Test
public void giveRangeOfLongs_whenSummedInParallel_shouldBeEqualToExpectedTotal() public void giveRangeOfLongs_whenSummedInParallel_shouldBeEqualToExpectedTotal()
throws InterruptedException, ExecutionException { throws InterruptedException, ExecutionException {
long firstNum = 1; long firstNum = 1;
long lastNum = 1_000_000; long lastNum = 1_000_000;
List<Long> aList = LongStream.range(firstNum, lastNum).boxed() List<Long> aList = LongStream.rangeClosed(firstNum, lastNum).boxed()
.collect(Collectors.toList()); .collect(Collectors.toList());
ForkJoinPool customThreadPool = new ForkJoinPool(4); ForkJoinPool customThreadPool = new ForkJoinPool(4);