import java.util.Random; import java.util.concurrent.*; public class FindMaxRunner { static ForkJoinPool fjPool = new ForkJoinPool(); /** * @param args */ public static void main(String[] args) { int arrSize = 999999; int[] arr = new int[arrSize]; Random r = new Random(); for(int i = 0; i < arr.length; i++) { arr[i] = (int) r.nextInt(100); // from 0 to 99 } // now stick in our max, let's say 500, into the array somewhere arr[4939] = 500; // now we'll use parallelism to try and find what the max array # is int max = fjPool.invoke(new FindMax(arr, 0, arr.length)); System.out.println("max found was " + max); } }