1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
485 |
|
try { |
486 |
|
p.execute(new CheckedRunnable() { |
487 |
|
public void realRun() throws InterruptedException { |
488 |
– |
threadStarted.countDown(); |
488 |
|
assertFalse(p.isTerminated()); |
489 |
+ |
threadStarted.countDown(); |
490 |
|
done.await(); |
491 |
|
}}); |
492 |
|
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
493 |
+ |
assertFalse(p.isTerminating()); |
494 |
|
done.countDown(); |
495 |
|
} finally { |
496 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
510 |
|
assertFalse(p.isTerminating()); |
511 |
|
p.execute(new CheckedRunnable() { |
512 |
|
public void realRun() throws InterruptedException { |
512 |
– |
threadStarted.countDown(); |
513 |
|
assertFalse(p.isTerminating()); |
514 |
+ |
threadStarted.countDown(); |
515 |
|
done.await(); |
516 |
|
}}); |
517 |
|
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
672 |
|
public void testShutDown2() throws InterruptedException { |
673 |
|
ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
674 |
|
p.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); |
675 |
+ |
assertFalse(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); |
676 |
+ |
assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); |
677 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
678 |
|
for (int i = 0; i < tasks.length; i++) |
679 |
|
tasks[i] = p.schedule(new NoOpRunnable(), |
697 |
|
*/ |
698 |
|
public void testShutDown3() throws InterruptedException { |
699 |
|
ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
700 |
+ |
assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); |
701 |
+ |
assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); |
702 |
|
p.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); |
703 |
+ |
assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); |
704 |
+ |
assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); |
705 |
|
ScheduledFuture task = |
706 |
|
p.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, MILLISECONDS); |
707 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
720 |
|
*/ |
721 |
|
public void testShutDown4() throws InterruptedException { |
722 |
|
ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
716 |
– |
p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); |
723 |
|
final CountDownLatch counter = new CountDownLatch(2); |
724 |
|
try { |
725 |
+ |
p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); |
726 |
+ |
assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); |
727 |
+ |
assertTrue(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); |
728 |
|
final Runnable r = new CheckedRunnable() { |
729 |
|
public void realRun() { |
730 |
|
counter.countDown(); |