ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ScheduledExecutorSubclassTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.48 by jsr166, Mon Oct 5 21:42:48 2015 UTC vs.
Revision 1.49 by jsr166, Mon Oct 5 21:54:33 2015 UTC

# Line 662 | Line 662 | public class ScheduledExecutorSubclassTe
662       * purge removes cancelled tasks from the queue
663       */
664      public void testPurge() throws InterruptedException {
665 +        final ScheduledFuture[] tasks = new ScheduledFuture[5];
666 +        final Runnable releaser = new Runnable() { public void run() {
667 +            for (ScheduledFuture task : tasks)
668 +                if (task != null) task.cancel(true); }};
669          final CustomExecutor p = new CustomExecutor(1);
670 <        ScheduledFuture[] tasks = new ScheduledFuture[5];
671 <        for (int i = 0; i < tasks.length; i++)
672 <            tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(),
673 <                                  LONG_DELAY_MS, MILLISECONDS);
670 <        try {
670 >        try (PoolCleaner cleaner = cleaner(p, releaser)) {
671 >            for (int i = 0; i < tasks.length; i++)
672 >                tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(),
673 >                                      LONG_DELAY_MS, MILLISECONDS);
674              int max = tasks.length;
675              if (tasks[4].cancel(true)) --max;
676              if (tasks[3].cancel(true)) --max;
# Line 679 | Line 682 | public class ScheduledExecutorSubclassTe
682                  long count = p.getTaskCount();
683                  if (count == max)
684                      return;
685 <            } while (millisElapsedSince(startTime) < MEDIUM_DELAY_MS);
685 >            } while (millisElapsedSince(startTime) < LONG_DELAY_MS);
686              fail("Purge failed to remove cancelled tasks");
684        } finally {
685            for (ScheduledFuture task : tasks)
686                task.cancel(true);
687            joinPool(p);
687          }
688      }
689  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines