Java 类java.util.concurrent.RecursiveAction 实例源码

项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * pollNextLocalTask returns most recent unexecuted task without
 * executing it
 */
public void testPollNextLocalTask() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertSame(f, pollNextLocalTask());
            helpQuiesce();
            checkNotDone(f);
            assertEquals(34, g.number);
            checkCompletedNormally(g);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * get of a forked task throws exception when task completes abnormally
 */
public void testAbnormalForkGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FailingAsyncFib f = new FailingAsyncFib(8);
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (ExecutionException success) {
                Throwable cause = success.getCause();
                assertTrue(cause instanceof FJException);
                checkCompletedAbnormally(f, cause);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testAbnormalForkGet(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FailingAsyncFib f = new FailingAsyncFib(8);
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (ExecutionException success) {
                Throwable cause = success.getCause();
                assertTrue(cause instanceof FJException);
                checkCompletedAbnormally(f, cause);
            }
        }};
    testInvokeOnPool(pool, a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(t1, t2) throw exception if any task does
 */
public void testAbnormalInvokeAll2Singleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            FailingAsyncFib g = new FailingAsyncFib(9);
            ForkJoinTask[] tasks = { f, g };
            shuffle(tasks);
            try {
                invokeAll(tasks);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(g, success);
            }
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * join of a forked task throws exception when task cancelled
 */
public void testCancelledForkJoinSingleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.join();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(collection) throws exception if any task does
 */
public void testAbnormalInvokeAllCollectionSingleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FailingAsyncFib f = new FailingAsyncFib(8);
            AsyncFib g = new AsyncFib(9);
            AsyncFib h = new AsyncFib(7);
            ForkJoinTask[] tasks = { f, g, h };
            shuffle(tasks);
            try {
                invokeAll(Arrays.asList(tasks));
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(tasks) with > 2 argument throws exception if any task does
 */
public void testAbnormalInvokeAll3() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            FailingAsyncFib g = new FailingAsyncFib(9);
            AsyncFib h = new AsyncFib(7);
            ForkJoinTask[] tasks = { f, g, h };
            shuffle(tasks);
            try {
                invokeAll(tasks);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(g, success);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testAbnormalInvokeAll2(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            FailingAsyncFib g = new FailingAsyncFib(9);
            ForkJoinTask[] tasks = { f, g };
            shuffle(tasks);
            try {
                invokeAll(tasks[0], tasks[1]);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(g, success);
            }
        }};
    testInvokeOnPool(pool, a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * join of a forked task throws exception when task cancelled
 */
public void testCancelledForkJoin() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.join();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
/**
 * getSurplusQueuedTaskCount returns > 0 when
 * there are more tasks than threads
 */
public void testGetSurplusQueuedTaskCount() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib h = new AsyncFib(7);
            assertSame(h, h.fork());
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertTrue(getSurplusQueuedTaskCount() > 0);
            helpQuiesce();
            assertEquals(0, getSurplusQueuedTaskCount());
            f.checkCompletedNormally();
            g.checkCompletedNormally();
            h.checkCompletedNormally();
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
/**
 * peekNextLocalTask returns most recent unexecuted task.
 */
public void testPeekNextLocalTask() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertSame(f, peekNextLocalTask());
            assertNull(f.join());
            f.checkCompletedNormally();
            helpQuiesce();
            g.checkCompletedNormally();
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * pollNextLocalTask returns least recent unexecuted task without
 * executing it, in async mode
 */
public void testPollNextLocalTaskAsync() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertSame(g, pollNextLocalTask());
            helpQuiesce();
            assertEquals(21, f.number);
            checkCompletedNormally(f);
            checkNotDone(g);
        }};
    testInvokeOnPool(asyncSingletonPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * getSurplusQueuedTaskCount returns > 0 when
 * there are more tasks than threads
 */
public void testGetSurplusQueuedTaskCount() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction h = new FibAction(7);
            assertSame(h, h.fork());
            FibAction g = new FibAction(9);
            assertSame(g, g.fork());
            FibAction f = new FibAction(8);
            assertSame(f, f.fork());
            assertTrue(getSurplusQueuedTaskCount() > 0);
            helpQuiesce();
            assertEquals(0, getSurplusQueuedTaskCount());
            checkCompletedNormally(f);
            checkCompletedNormally(g);
            checkCompletedNormally(h);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * timed get of a forked task throws exception when task cancelled
 */
public void testCancelledForkTimedGetSingleton() throws Exception {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            AsyncFib f = new AsyncFib(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.get(LONG_DELAY_MS, MILLISECONDS);
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * get of a forked task throws exception when task completes abnormally
 */
public void testAbnormalForkGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FailingFibAction f = new FailingFibAction(8);
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (ExecutionException success) {
                Throwable cause = success.getCause();
                assertTrue(cause instanceof FJException);
                checkCompletedAbnormally(f, cause);
            }
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * timed get of a forked task throws exception when task completes abnormally
 */
public void testAbnormalForkTimedGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FailingFibAction f = new FailingFibAction(8);
            assertSame(f, f.fork());
            try {
                f.get(LONG_DELAY_MS, MILLISECONDS);
                shouldThrow();
            } catch (ExecutionException success) {
                Throwable cause = success.getCause();
                assertTrue(cause instanceof FJException);
                checkCompletedAbnormally(f, cause);
            }
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(collection) invokes all tasks in the collection
 */
public void testInvokeAllCollection() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            AsyncFib g = new AsyncFib(9);
            AsyncFib h = new AsyncFib(7);
            HashSet set = new HashSet();
            set.add(f);
            set.add(g);
            set.add(h);
            invokeAll(set);
            assertEquals(21, f.number);
            assertEquals(34, g.number);
            assertEquals(13, h.number);
            checkCompletedNormally(f);
            checkCompletedNormally(g);
            checkCompletedNormally(h);
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * A reinitialized normally completed task may be re-invoked
 */
public void testReinitialize() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction f = new FibAction(8);
            checkNotDone(f);

            for (int i = 0; i < 3; i++) {
                assertNull(f.invoke());
                assertEquals(21, f.result);
                checkCompletedNormally(f);
                f.reinitialize();
                checkNotDone(f);
            }
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * A reinitialized abnormally completed task may be re-invoked
 */
public void testReinitializeAbnormal() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FailingFibAction f = new FailingFibAction(8);
            checkNotDone(f);

            for (int i = 0; i < 3; i++) {
                try {
                    f.invoke();
                    shouldThrow();
                } catch (FJException success) {
                    checkCompletedAbnormally(f, success);
                }
                f.reinitialize();
                checkNotDone(f);
            }
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * invokeAll(collection) invokes all tasks in the collection
 */
public void testInvokeAllCollection() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction f = new FibAction(8);
            FibAction g = new FibAction(9);
            FibAction h = new FibAction(7);
            HashSet set = new HashSet();
            set.add(f);
            set.add(g);
            set.add(h);
            invokeAll(set);
            assertTrue(f.isDone());
            assertTrue(g.isDone());
            assertTrue(h.isDone());
            checkCompletedNormally(f);
            assertEquals(21, f.result);
            checkCompletedNormally(g);
            assertEquals(34, g.result);
            checkCompletedNormally(g);
            assertEquals(13, h.result);
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) {
    try (PoolCleaner cleaner = cleaner(pool)) {
        assertFalse(a.isDone());
        assertFalse(a.isCompletedNormally());
        assertFalse(a.isCompletedAbnormally());
        assertFalse(a.isCancelled());
        assertNull(a.getException());
        assertNull(a.getRawResult());

        assertNull(pool.invoke(a));

        assertTrue(a.isDone());
        assertTrue(a.isCompletedNormally());
        assertFalse(a.isCompletedAbnormally());
        assertFalse(a.isCancelled());
        assertNull(a.getException());
        assertNull(a.getRawResult());
    }
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * get of a forked task throws exception when task cancelled
 */
public void testCancelledForkGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            AsyncFib f = new AsyncFib(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinPool8Test.java   
/**
 * invokeAll(collection) throws exception if any task does
 */
public void testAbnormalInvokeAllCollection() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FailingFibAction f = new FailingFibAction(8);
            FibAction g = new FibAction(9);
            FibAction h = new FibAction(7);
            HashSet set = new HashSet();
            set.add(f);
            set.add(g);
            set.add(h);
            try {
                invokeAll(set);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }};
    checkInvoke(a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * pollTask returns an unexecuted task without executing it, in
 * async mode
 */
public void testPollTaskAsync() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertSame(g, pollTask());
            helpQuiesce();
            assertEquals(21, f.number);
            checkCompletedNormally(f);
            checkNotDone(g);
        }};
    testInvokeOnPool(asyncSingletonPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * invokeAll(tasks) with > 2 argument invokes tasks
 */
public void testInvokeAll3() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction f = new FibAction(8);
            FibAction g = new FibAction(9);
            FibAction h = new FibAction(7);
            invokeAll(f, g, h);
            assertTrue(f.isDone());
            assertTrue(g.isDone());
            assertTrue(h.isDone());
            checkCompletedNormally(f);
            assertEquals(21, f.result);
            checkCompletedNormally(g);
            assertEquals(34, g.result);
            checkCompletedNormally(g);
            assertEquals(13, h.result);
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * invokeAll(collection) throws exception if any task does
 */
public void testAbnormalInvokeAllCollection() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FailingFibAction f = new FailingFibAction(8);
            FibAction g = new FibAction(9);
            FibAction h = new FibAction(7);
            HashSet set = new HashSet();
            set.add(f);
            set.add(g);
            set.add(h);
            try {
                invokeAll(set);
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * get of a forked task throws exception when task completes abnormally
 */
public void testAbnormalForkGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FailingFibAction f = new FailingFibAction(8);
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (ExecutionException success) {
                Throwable cause = success.getCause();
                assertTrue(cause instanceof FJException);
                checkCompletedAbnormally(f, cause);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * join of a forked task throws exception when task cancelled
 */
public void testCancelledForkJoin() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction f = new FibAction(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.join();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * get of a forked task throws exception when task cancelled
 */
public void testCancelledForkGet() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            FibAction f = new FibAction(8);
            assertTrue(f.cancel(true));
            assertSame(f, f.fork());
            try {
                f.get();
                shouldThrow();
            } catch (CancellationException success) {
                checkCancelled(f);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(tasks) with > 2 argument invokes tasks
 */
public void testInvokeAll3Singleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            AsyncFib g = new AsyncFib(9);
            AsyncFib h = new AsyncFib(7);
            invokeAll(f, g, h);
            assertEquals(21, f.number);
            assertEquals(34, g.number);
            assertEquals(13, h.number);
            checkCompletedNormally(f);
            checkCompletedNormally(g);
            checkCompletedNormally(h);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * completeExceptionally(null) surprisingly has the same effect as
 * completeExceptionally(new RuntimeException())
 */
public void testCompleteExceptionally_null() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            f.completeExceptionally(null);
            try {
                f.invoke();
                shouldThrow();
            } catch (RuntimeException success) {
                assertSame(success.getClass(), RuntimeException.class);
                assertNull(success.getCause());
                checkCompletedAbnormally(f, success);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:RecursiveActionTest.java   
/**
 * A reinitialized normally completed task may be re-invoked
 */
public void testReinitialize() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FibAction f = new FibAction(8);
            checkNotDone(f);

            for (int i = 0; i < 3; i++) {
                assertNull(f.invoke());
                assertEquals(21, f.result);
                checkCompletedNormally(f);
                f.reinitialize();
                checkNotDone(f);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invokeAll(t1, t2) invokes all task arguments
 */
public void testInvokeAll2Singleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            AsyncFib g = new AsyncFib(9);
            invokeAll(f, g);
            assertEquals(21, f.number);
            assertEquals(34, g.number);
            checkCompletedNormally(f);
            checkCompletedNormally(g);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * quietlyJoin of a forked task returns when task completes
 */
public void testForkQuietlyJoinSingleton() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            f.quietlyJoin();
            assertEquals(21, f.number);
            checkCompletedNormally(f);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * invoke task throws exception when task completes abnormally
 */
public void testAbnormalInvoke() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            FailingAsyncFib f = new FailingAsyncFib(8);
            try {
                f.invoke();
                shouldThrow();
            } catch (FJException success) {
                checkCompletedAbnormally(f, success);
            }
        }};
    testInvokeOnPool(mainPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testQuietlyInvoke(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            f.quietlyInvoke();
            f.checkCompletedNormally();
        }};
    testInvokeOnPool(pool, a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testForkJoin(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertNull(f.join());
            f.checkCompletedNormally();
        }};
    testInvokeOnPool(pool, a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testForkGet(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertNull(f.get());
            f.checkCompletedNormally();
        }};
    testInvokeOnPool(pool, a);
}
项目:openjdk-jdk10    文件:ForkJoinTaskTest.java   
/**
 * tryUnfork returns true for most recent unexecuted task,
 * and suppresses execution
 */
public void testTryUnfork() {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() {
            AsyncFib g = new AsyncFib(9);
            assertSame(g, g.fork());
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            assertTrue(f.tryUnfork());
            helpQuiesce();
            checkNotDone(f);
            checkCompletedNormally(g);
        }};
    testInvokeOnPool(singletonPool(), a);
}
项目:openjdk-jdk10    文件:ForkJoinTask8Test.java   
public void testForkTimedGetNullTimeUnit(ForkJoinPool pool) {
    RecursiveAction a = new CheckedRecursiveAction() {
        protected void realCompute() throws Exception {
            AsyncFib f = new AsyncFib(8);
            assertSame(f, f.fork());
            try {
                f.get(randomTimeout(), null);
                shouldThrow();
            } catch (NullPointerException success) {}
        }};
    testInvokeOnPool(pool, a);
}