Skip to content

Commit a1312e9

Browse files
ola-dotunadamd1985
authored andcommitted
Custom Thread Pools In Java 8 Parallel Streams (eugenp#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
1 parent c350e8b commit a1312e9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core-java/src/test/java/org/baeldung/java/streams/ThreadPoolInParallelStream.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.baeldung.java.streams;
2-
2+
33
import org.junit.Test;
44

55
import java.util.ArrayList;
@@ -17,18 +17,18 @@ public class ThreadPoolInParallelStream {
1717

1818
@Test
1919
public void giveRangeOfLongs_whenSummedInParallel_shouldBeEqualToExpectedTotal()
20-
throws InterruptedException, ExecutionException {
20+
throws InterruptedException, ExecutionException {
2121
long firstNum = 1;
2222
long lastNum = 1_000_000;
2323

24-
List<Long> aList = LongStream.range(firstNum, lastNum).boxed()
24+
List<Long> aList = LongStream.rangeClosed(firstNum, lastNum).boxed()
2525
.collect(Collectors.toList());
2626

2727
ForkJoinPool customThreadPool = new ForkJoinPool(4);
2828
long actualTotal = customThreadPool.submit(() -> aList.parallelStream()
2929
.reduce(0L, Long::sum)).get();
3030

31-
assertEquals((lastNum + firstNum) * lastNum / 2, actualTotal);
31+
assertEquals((lastNum + firstNum) * lastNum / 2, actualTotal);
3232
}
3333

3434
@Test

0 commit comments

Comments
 (0)