BAEL-612: Example usage of ForkJoinTask
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.concurrent.future;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FactorialSquareCalculatorUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalculatesFactorialSquare_thenReturnCorrectValue() {
|
||||
ForkJoinPool forkJoinPool = new ForkJoinPool();
|
||||
|
||||
FactorialSquareCalculator calculator = new FactorialSquareCalculator(10);
|
||||
|
||||
forkJoinPool.execute(calculator);
|
||||
|
||||
assertEquals("The sum of the squares from 1 to 10 is 385", 385, calculator.join().intValue());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user