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

Comparing jsr166/src/test/tck/ScheduledExecutorTest.java (file contents):
Revision 1.18 by dl, Wed Jan 21 01:47:07 2004 UTC vs.
Revision 1.19 by dl, Thu Jan 22 14:07:50 2004 UTC

# Line 497 | Line 497 | public class ScheduledExecutorTest exten
497          ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
498          ScheduledFuture[] tasks = new ScheduledFuture[5];
499          for(int i = 0; i < 5; i++){
500 <            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
500 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
501          }
502          try {
503              Thread.sleep(SHORT_DELAY_MS);
# Line 525 | Line 525 | public class ScheduledExecutorTest exten
525          ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
526          ScheduledFuture[] tasks = new ScheduledFuture[5];
527          for(int i = 0; i < 5; i++){
528 <            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
528 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
529 >        }
530 >        try {
531 >            int max = 5;
532 >            if (tasks[4].cancel(true)) --max;
533 >            if (tasks[3].cancel(true)) --max;
534 >            // There must eventually be an interference-free point at
535 >            // which purge will not fail. (At worst, when queue is empty.)
536 >            int k;
537 >            for (k = 0; k < SMALL_DELAY_MS; ++k) {
538 >                p1.purge();
539 >                long count = p1.getTaskCount();
540 >                if (count >= 0 && count <= max)
541 >                    break;
542 >                Thread.sleep(1);
543 >            }
544 >            assertTrue(k < SMALL_DELAY_MS);
545 >        } catch(Exception e) {
546 >            unexpectedException();
547 >        } finally {
548 >            joinPool(p1);
549          }
530        int max = 5;
531        if (tasks[4].cancel(true)) --max;
532        if (tasks[3].cancel(true)) --max;
533        p1.purge();
534        long count = p1.getTaskCount();
535        assertTrue(count > 0 && count <= max);
536        joinPool(p1);
550      }
551  
552      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines