本文整理匯總了Java中java.util.concurrent.ForkJoinTask.isDone方法的典型用法代碼示例。如果您正苦於以下問題:Java ForkJoinTask.isDone方法的具體用法?Java ForkJoinTask.isDone怎麽用?Java ForkJoinTask.isDone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.concurrent.ForkJoinTask
的用法示例。
在下文中一共展示了ForkJoinTask.isDone方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testAwaitQuiescence1
import java.util.concurrent.ForkJoinTask; //導入方法依賴的package包/類
/**
* awaitQuiescence by a worker is equivalent in effect to
* ForkJoinTask.helpQuiesce()
*/
public void testAwaitQuiescence1() throws Exception {
final ForkJoinPool p = new ForkJoinPool();
try (PoolCleaner cleaner = cleaner(p)) {
final long startTime = System.nanoTime();
assertTrue(p.isQuiescent());
ForkJoinTask a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
assertSame(f, f.fork());
assertSame(p, ForkJoinTask.getPool());
boolean quiescent = p.awaitQuiescence(LONG_DELAY_MS, MILLISECONDS);
assertTrue(quiescent);
assertFalse(p.isQuiescent());
while (!f.isDone()) {
assertFalse(p.getAsyncMode());
assertFalse(p.isShutdown());
assertFalse(p.isTerminating());
assertFalse(p.isTerminated());
Thread.yield();
}
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
assertFalse(p.isQuiescent());
assertEquals(0, ForkJoinTask.getQueuedTaskCount());
assertEquals(21, f.result);
}};
p.execute(a);
while (!a.isDone() || !p.isQuiescent()) {
assertFalse(p.getAsyncMode());
assertFalse(p.isShutdown());
assertFalse(p.isTerminating());
assertFalse(p.isTerminated());
Thread.yield();
}
assertEquals(0, p.getQueuedTaskCount());
assertFalse(p.getAsyncMode());
assertEquals(0, p.getQueuedSubmissionCount());
assertFalse(p.hasQueuedSubmissions());
while (p.getActiveThreadCount() != 0
&& millisElapsedSince(startTime) < LONG_DELAY_MS)
Thread.yield();
assertFalse(p.isShutdown());
assertFalse(p.isTerminating());
assertFalse(p.isTerminated());
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
}
}