Last active
August 29, 2015 14:24
-
-
Save fmamud/13b08da2a25885cac1fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package forkjoin; | |
import java.math.BigInteger; | |
import java.util.concurrent.ForkJoinPool; | |
public class Main { | |
public static void main(String[] args) { | |
int n = 50, processors = Runtime.getRuntime().availableProcessors(); | |
System.out.println("Fibonacci num: " + n); | |
System.out.println("Processors: " + processors); | |
long time = System.nanoTime(); | |
FibonacciProblem fib = new FibonacciProblem(n); | |
FibonacciTask fibTask = new FibonacciTask(fib); | |
ForkJoinPool pool = new ForkJoinPool(); | |
Long result1 = pool.invoke(fibTask); | |
System.out.println("Result F/J: " + result1); | |
System.out.println("Time F/J: " + ((System.nanoTime() - time) / 1_000_000) + "ms"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment