607 |
|
final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
608 |
|
try (PoolCleaner cleaner = cleaner(p, releaser)) { |
609 |
|
for (int i = 0; i < tasks.length; i++) |
610 |
< |
tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(), |
610 |
> |
tasks[i] = p.schedule(possiblyInterruptedRunnable(SMALL_DELAY_MS), |
611 |
|
LONG_DELAY_MS, MILLISECONDS); |
612 |
|
int max = tasks.length; |
613 |
|
if (tasks[4].cancel(true)) --max; |
639 |
|
Runnable waiter = new CheckedRunnable() { public void realRun() { |
640 |
|
threadsStarted.countDown(); |
641 |
|
try { |
642 |
< |
MILLISECONDS.sleep(2 * LONG_DELAY_MS); |
642 |
> |
MILLISECONDS.sleep(LONGER_DELAY_MS); |
643 |
|
} catch (InterruptedException success) {} |
644 |
|
ran.getAndIncrement(); |
645 |
|
}}; |
804 |
|
immediates.forEach( |
805 |
|
f -> assertTrue(((ScheduledFuture)f).getDelay(NANOSECONDS) <= 0L)); |
806 |
|
|
807 |
< |
Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream()) |
807 |
> |
Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream) |
808 |
|
.forEach(f -> assertFalse(f.isDone())); |
809 |
|
|
810 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
858 |
|
|
859 |
|
assertTrue(q.isEmpty()); |
860 |
|
|
861 |
< |
Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream()) |
861 |
> |
Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream) |
862 |
|
.forEach(f -> assertTrue(f.isDone())); |
863 |
|
|
864 |
|
for (Future<?> f : immediates) assertNull(f.get()); |