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.21 by dl, Thu Jan 22 15:17:35 2004 UTC

# Line 144 | Line 144 | public class ScheduledExecutorTest exten
144              // an execution per SHORT delay, but no more than one SHORT more
145              assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
146              assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
147            assertTrue(h.isDone());
147              joinPool(p1);
148          } catch(Exception e){
149              unexpectedException();
# Line 165 | Line 164 | public class ScheduledExecutorTest exten
164              int c = counter.count.get();
165              assertTrue(c >= SMALL_DELAY_MS / SHORT_DELAY_MS);
166              assertTrue(c <= SMALL_DELAY_MS + SHORT_DELAY_MS);
168            assertTrue(h.isDone());
167              joinPool(p1);
168          } catch(Exception e){
169              unexpectedException();
# Line 525 | Line 523 | public class ScheduledExecutorTest exten
523          ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
524          ScheduledFuture[] tasks = new ScheduledFuture[5];
525          for(int i = 0; i < 5; i++){
526 <            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), 1, TimeUnit.MILLISECONDS);
526 >            tasks[i] = p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
527 >        }
528 >        try {
529 >            int max = 5;
530 >            if (tasks[4].cancel(true)) --max;
531 >            if (tasks[3].cancel(true)) --max;
532 >            // There must eventually be an interference-free point at
533 >            // which purge will not fail. (At worst, when queue is empty.)
534 >            int k;
535 >            for (k = 0; k < SMALL_DELAY_MS; ++k) {
536 >                p1.purge();
537 >                long count = p1.getTaskCount();
538 >                if (count >= 0 && count <= max)
539 >                    break;
540 >                Thread.sleep(1);
541 >            }
542 >            assertTrue(k < SMALL_DELAY_MS);
543 >        } catch(Exception e) {
544 >            unexpectedException();
545 >        } finally {
546 >            joinPool(p1);
547          }
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);
548      }
549  
550      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines