233 |
|
* performs its defined action |
234 |
|
*/ |
235 |
|
public void testSetUncaughtExceptionHandler() throws InterruptedException { |
236 |
< |
final CountDownLatch uncaughtExceptionHappened = new CountDownLatch(1); |
236 |
> |
final CountDownLatch uehInvoked = new CountDownLatch(1); |
237 |
|
final Thread.UncaughtExceptionHandler eh = |
238 |
|
new Thread.UncaughtExceptionHandler() { |
239 |
|
public void uncaughtException(Thread t, Throwable e) { |
240 |
< |
uncaughtExceptionHappened.countDown(); |
240 |
> |
uehInvoked.countDown(); |
241 |
|
}}; |
242 |
|
ForkJoinPool p = new ForkJoinPool(1, new FailingThreadFactory(), |
243 |
|
eh, false); |
244 |
|
try { |
245 |
|
assertSame(eh, p.getUncaughtExceptionHandler()); |
246 |
< |
p.execute(new FailingTask()); |
247 |
< |
uncaughtExceptionHappened.await(); |
246 |
> |
p.execute(new FibTask(8)); |
247 |
> |
assertTrue(uehInvoked.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
248 |
|
} finally { |
249 |
|
p.shutdownNow(); // failure might have prevented processing task |
250 |
|
joinPool(p); |
259 |
|
public void testisQuiescent() throws InterruptedException { |
260 |
|
ForkJoinPool p = new ForkJoinPool(2); |
261 |
|
try { |
262 |
+ |
assertTrue(p.isQuiescent()); |
263 |
|
p.invoke(new FibTask(20)); |
264 |
|
assertSame(ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
265 |
|
p.getFactory()); |
266 |
< |
Thread.sleep(MEDIUM_DELAY_MS); |
266 |
> |
Thread.sleep(SMALL_DELAY_MS); |
267 |
|
assertTrue(p.isQuiescent()); |
268 |
|
assertFalse(p.getAsyncMode()); |
269 |
|
assertEquals(0, p.getActiveThreadCount()); |