5 |
|
*/ |
6 |
|
|
7 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
8 |
– |
import static java.util.concurrent.TimeUnit.SECONDS; |
8 |
|
|
9 |
|
import java.util.HashSet; |
10 |
|
import java.util.concurrent.CancellationException; |
83 |
|
|
84 |
|
Thread.currentThread().interrupt(); |
85 |
|
try { |
86 |
< |
a.get(5L, SECONDS); |
86 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
87 |
|
shouldThrow(); |
88 |
|
} catch (InterruptedException success) { |
89 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
90 |
|
} |
91 |
|
|
92 |
|
try { |
93 |
< |
a.get(0L, SECONDS); |
93 |
> |
a.get(randomExpiredTimeout(), randomTimeUnit()); |
94 |
|
shouldThrow(); |
95 |
|
} catch (TimeoutException success) { |
96 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
106 |
|
assertNull(a.join()); |
107 |
|
assertFalse(a.cancel(false)); |
108 |
|
assertFalse(a.cancel(true)); |
109 |
+ |
|
110 |
+ |
Object v1 = null, v2 = null; |
111 |
|
try { |
112 |
< |
assertNull(a.get()); |
113 |
< |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
113 |
< |
try { |
114 |
< |
assertNull(a.get(5L, SECONDS)); |
112 |
> |
v1 = a.get(); |
113 |
> |
v2 = a.get(randomTimeout(), randomTimeUnit()); |
114 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
115 |
+ |
assertNull(v1); |
116 |
+ |
assertNull(v2); |
117 |
|
} |
118 |
|
|
119 |
|
void checkCancelled(ForkJoinTask a) { |
137 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
138 |
|
|
139 |
|
try { |
140 |
< |
a.get(5L, SECONDS); |
140 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
141 |
|
shouldThrow(); |
142 |
|
} catch (CancellationException success) { |
143 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
168 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
169 |
|
|
170 |
|
try { |
171 |
< |
a.get(5L, SECONDS); |
171 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
172 |
|
shouldThrow(); |
173 |
|
} catch (ExecutionException success) { |
174 |
|
assertSame(t.getClass(), success.getCause().getClass()); |
357 |
|
protected void realCompute() throws Exception { |
358 |
|
FibAction f = new FibAction(8); |
359 |
|
assertSame(f, f.fork()); |
360 |
< |
assertNull(f.get(5L, SECONDS)); |
360 |
> |
assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); |
361 |
|
assertEquals(21, f.result); |
362 |
|
checkCompletedNormally(f); |
363 |
|
}}; |
373 |
|
FibAction f = new FibAction(8); |
374 |
|
assertSame(f, f.fork()); |
375 |
|
try { |
376 |
< |
f.get(5L, null); |
376 |
> |
f.get(randomTimeout(), null); |
377 |
|
shouldThrow(); |
378 |
|
} catch (NullPointerException success) {} |
379 |
|
}}; |
473 |
|
FailingFibAction f = new FailingFibAction(8); |
474 |
|
assertSame(f, f.fork()); |
475 |
|
try { |
476 |
< |
f.get(5L, SECONDS); |
476 |
> |
f.get(LONG_DELAY_MS, MILLISECONDS); |
477 |
|
shouldThrow(); |
478 |
|
} catch (ExecutionException success) { |
479 |
|
Throwable cause = success.getCause(); |
565 |
|
assertTrue(f.cancel(true)); |
566 |
|
assertSame(f, f.fork()); |
567 |
|
try { |
568 |
< |
f.get(5L, SECONDS); |
568 |
> |
f.get(LONG_DELAY_MS, MILLISECONDS); |
569 |
|
shouldThrow(); |
570 |
|
} catch (CancellationException success) { |
571 |
|
checkCancelled(f); |
1041 |
|
CCF f = new LCCF(null, 8); |
1042 |
|
assertSame(f, f.fork()); |
1043 |
|
try { |
1044 |
< |
f.get(5L, null); |
1044 |
> |
f.get(randomTimeout(), null); |
1045 |
|
shouldThrow(); |
1046 |
|
} catch (NullPointerException success) {} |
1047 |
|
}}; |
1534 |
|
* timeout elapsed |
1535 |
|
*/ |
1536 |
|
public void testAwaitQuiescence2() throws Exception { |
1537 |
< |
/** |
1537 |
> |
/* |
1538 |
|
* """It is possible to disable or limit the use of threads in the |
1539 |
|
* common pool by setting the parallelism property to zero. However |
1540 |
|
* doing so may cause unjoined tasks to never be executed.""" |