Java Code Examples for java.util.concurrent.RecursiveTask#join()
The following examples show how to use
java.util.concurrent.RecursiveTask#join() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadLessCommon.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 2
Source File: ThreadLessCommon.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 3
Source File: ThreadLessCommon.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 4
Source File: ThreadLessCommon.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 5
Source File: ThreadLessCommon.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 6
Source File: ThreadLessCommon.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 7
Source File: ThreadLessCommon.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 8
Source File: ThreadLessCommon.java From hottub with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 9
Source File: ThreadLessCommon.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 10
Source File: ThreadLessCommon.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 11
Source File: ThreadLessCommon.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 12
Source File: ThreadLessCommon.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 13
Source File: ThreadLessCommon.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static void realMain(String[] args) throws Throwable { if (debug) { String pp = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); System.out.println( "java.util.concurrent.ForkJoinPool.common.parallelism:" + pp); String tf = System.getProperty( "java.util.concurrent.ForkJoinPool.common.threadFactory"); System.out.println( "java.util.concurrent.ForkJoinPool.common.threadFactory:" + tf); } long from = 0, to = 50000; RecursiveTask<Long> task = new SumTask(from, to, Thread.currentThread()); long sum = task.invoke(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); task.fork(); sum = task.join(); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); sum = ForkJoinPool.commonPool().invoke(task.fork()); System.out.printf("%nSum: from [%d] to [%d] = [%d]%n", from, to, sum); }
Example 14
Source File: RecursiveTaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Waits for the task to complete, and checks that when it does, * it will have an Integer result equals to the given int. */ void checkCompletesNormally(RecursiveTask<Integer> a, int expected) { Integer r = a.join(); assertEquals(expected, (int) r); checkCompletedNormally(a, r); }
Example 15
Source File: RecursiveTaskTest.java From j2objc with Apache License 2.0 | 4 votes |
/** * Waits for the task to complete, and checks that when it does, * it will have an Integer result equals to the given int. */ void checkCompletesNormally(RecursiveTask<Integer> a, int expected) { Integer r = a.join(); assertEquals(expected, (int) r); checkCompletedNormally(a, r); }