203 |
|
RunnableCounter counter = new RunnableCounter(); |
204 |
|
ScheduledFuture h = |
205 |
|
p.scheduleAtFixedRate(counter, 0, 1, MILLISECONDS); |
206 |
< |
Thread.sleep(SMALL_DELAY_MS); |
206 |
> |
delay(SMALL_DELAY_MS); |
207 |
|
h.cancel(true); |
208 |
|
int c = counter.count.get(); |
209 |
|
// By time scaling conventions, we must have at least |
221 |
|
RunnableCounter counter = new RunnableCounter(); |
222 |
|
ScheduledFuture h = |
223 |
|
p.scheduleWithFixedDelay(counter, 0, 1, MILLISECONDS); |
224 |
< |
Thread.sleep(SMALL_DELAY_MS); |
224 |
> |
delay(SMALL_DELAY_MS); |
225 |
|
h.cancel(true); |
226 |
|
int c = counter.count.get(); |
227 |
|
assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS); |
291 |
|
/** |
292 |
|
* schedule callable throws RejectedExecutionException if shutdown |
293 |
|
*/ |
294 |
< |
public void testSchedule3_RejectedExecutionException() { |
295 |
< |
CustomExecutor se = new CustomExecutor(1); |
296 |
< |
try { |
297 |
< |
se.shutdown(); |
298 |
< |
se.schedule(new NoOpCallable(), |
299 |
< |
MEDIUM_DELAY_MS, MILLISECONDS); |
300 |
< |
shouldThrow(); |
301 |
< |
} catch (RejectedExecutionException success) { |
302 |
< |
} catch (SecurityException ok) { |
303 |
< |
} |
304 |
< |
joinPool(se); |
294 |
> |
public void testSchedule3_RejectedExecutionException() { |
295 |
> |
CustomExecutor se = new CustomExecutor(1); |
296 |
> |
try { |
297 |
> |
se.shutdown(); |
298 |
> |
se.schedule(new NoOpCallable(), |
299 |
> |
MEDIUM_DELAY_MS, MILLISECONDS); |
300 |
> |
shouldThrow(); |
301 |
> |
} catch (RejectedExecutionException success) { |
302 |
> |
} catch (SecurityException ok) { |
303 |
> |
} |
304 |
> |
joinPool(se); |
305 |
|
} |
306 |
|
|
307 |
|
/** |
382 |
|
assertEquals(0, p.getCompletedTaskCount()); |
383 |
|
threadProceed.countDown(); |
384 |
|
threadDone.await(); |
385 |
< |
Thread.sleep(SHORT_DELAY_MS); |
385 |
> |
delay(SHORT_DELAY_MS); |
386 |
|
assertEquals(1, p.getCompletedTaskCount()); |
387 |
|
} finally { |
388 |
|
joinPool(p); |
657 |
|
long count = p.getTaskCount(); |
658 |
|
if (count >= 0 && count <= max) |
659 |
|
break; |
660 |
< |
Thread.sleep(1); |
660 |
> |
delay(1); |
661 |
|
} |
662 |
|
assertTrue(k < SMALL_DELAY_MS); |
663 |
|
} finally { |