317 |
|
assertEquals(1, p.getActiveCount()); |
318 |
|
await(done); |
319 |
|
}}); |
320 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
320 |
> |
await(threadStarted); |
321 |
|
assertEquals(1, p.getActiveCount()); |
322 |
|
done.countDown(); |
323 |
|
} |
373 |
|
final ThreadPoolExecutor p = new ScheduledThreadPoolExecutor(THREADS); |
374 |
|
final CountDownLatch threadsStarted = new CountDownLatch(THREADS); |
375 |
|
final CountDownLatch done = new CountDownLatch(1); |
376 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
376 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
377 |
|
assertEquals(0, p.getLargestPoolSize()); |
378 |
|
for (int i = 0; i < THREADS; i++) |
379 |
|
p.execute(new CheckedRunnable() { |
382 |
|
await(done); |
383 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
384 |
|
}}); |
385 |
< |
assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
385 |
> |
await(threadsStarted); |
386 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
387 |
– |
done.countDown(); |
387 |
|
} |
388 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
389 |
|
} |
396 |
|
final ThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
397 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
398 |
|
final CountDownLatch done = new CountDownLatch(1); |
399 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
399 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
400 |
|
assertEquals(0, p.getPoolSize()); |
401 |
|
p.execute(new CheckedRunnable() { |
402 |
|
public void realRun() throws InterruptedException { |
404 |
|
assertEquals(1, p.getPoolSize()); |
405 |
|
await(done); |
406 |
|
}}); |
407 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
407 |
> |
await(threadStarted); |
408 |
|
assertEquals(1, p.getPoolSize()); |
410 |
– |
done.countDown(); |
409 |
|
} |
410 |
|
} |
411 |
|
|
426 |
|
threadStarted.countDown(); |
427 |
|
await(done); |
428 |
|
}}); |
429 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
429 |
> |
await(threadStarted); |
430 |
|
assertEquals(1, p.getTaskCount()); |
431 |
|
assertEquals(0, p.getCompletedTaskCount()); |
432 |
|
for (int i = 0; i < TASKS; i++) { |
512 |
|
threadStarted.countDown(); |
513 |
|
await(done); |
514 |
|
}}); |
515 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
515 |
> |
await(threadStarted); |
516 |
|
assertFalse(p.isTerminating()); |
517 |
|
done.countDown(); |
518 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
536 |
|
threadStarted.countDown(); |
537 |
|
await(done); |
538 |
|
}}); |
539 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
539 |
> |
await(threadStarted); |
540 |
|
assertFalse(p.isTerminating()); |
541 |
|
done.countDown(); |
542 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
563 |
|
}}; |
564 |
|
tasks[i] = p.schedule(r, 1, MILLISECONDS); |
565 |
|
} |
566 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
566 |
> |
await(threadStarted); |
567 |
|
BlockingQueue<Runnable> q = p.getQueue(); |
568 |
|
assertTrue(q.contains(tasks[tasks.length - 1])); |
569 |
|
assertFalse(q.contains(tasks[0])); |
588 |
|
}}; |
589 |
|
tasks[i] = p.schedule(r, 1, MILLISECONDS); |
590 |
|
} |
591 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
591 |
> |
await(threadStarted); |
592 |
|
BlockingQueue<Runnable> q = p.getQueue(); |
593 |
|
assertFalse(p.remove((Runnable)tasks[0])); |
594 |
|
assertTrue(q.contains((Runnable)tasks[4])); |
652 |
|
}}; |
653 |
|
for (int i = 0; i < count; i++) |
654 |
|
p.execute(waiter); |
655 |
< |
assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
655 |
> |
await(threadsStarted); |
656 |
|
assertEquals(poolSize, p.getActiveCount()); |
657 |
|
assertEquals(0, p.getCompletedTaskCount()); |
658 |
|
final List<Runnable> queuedTasks; |