Package java.util.concurrent

Examples of java.util.concurrent.ForkJoinPool.invoke()


        int[] arr2 = new int[arr1.length];
        System.arraycopy(arr1, 0, arr2, 0, arr1.length-1);
        MergeSort t = new MergeSort(Issue.getInitIssue(),0,arr1.length-1);
        ForkJoinPool pool = new ForkJoinPool(nThreads);
        Long start = System.nanoTime();
        pool.invoke(t);
        Long end = System.nanoTime();
        int[] result = t.getResult();
        System.out.println("Done. Result: time1 : " + (end - start));
        Long start2 = System.nanoTime();
        Arrays.sort(arr2, 0, arr1.length);
View Full Code Here


        long[] anArray = new long[100000];
        for (int i = 0; i < anArray.length - 1; i++)
            anArray[i] = i;
        RecursiveAction mainTask = new IncrementTask(anArray, 0, anArray.length);
        ForkJoinPool mainPool = new ForkJoinPool();
        mainPool.invoke(mainTask);
    }
}
View Full Code Here

    public static void main(String[] args) {
        int[] anArray = new int[Integer.MAX_VALUE/10];
        assert anArray[Integer.MAX_VALUE/10] == 0;
        RecursiveAction mainTask = new IncrementTask (anArray, 0, anArray.length);
        ForkJoinPool mainPool = new ForkJoinPool();
        mainPool.invoke(mainTask);
        assert anArray[Integer.MAX_VALUE/10] == 1;
        System.out.println(mainPool.getActiveThreadCount());
        System.out.println(mainPool.getStealCount());
    }
}
View Full Code Here

        SelectMaxProblem problem = new SelectMaxProblem(numbers, 0, size);
        MaxFJ mfj = new MaxFJ(problem, threshold);
        ForkJoinPool fjp = new ForkJoinPool(nThreads);

        final long start = System.nanoTime();
        fjp.invoke(mfj);
        final long mfjElapsed = System.nanoTime() - start;
        System.out.println("Result = " + mfj.result + ", elapsed nanos = " + mfjElapsed);

        MaxSerial serial = new MaxSerial(problem);
        final long startSerial = System.nanoTime();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.