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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.91 by jsr166, Sun Oct 4 03:27:46 2015 UTC vs.
Revision 1.92 by jsr166, Sun Oct 4 03:49:33 2015 UTC

# Line 1184 | Line 1184 | public class ThreadPoolExecutorTest exte
1184       * executor using DiscardOldestPolicy drops oldest task if saturated.
1185       */
1186      public void testSaturatedExecute4() {
1187 <        RejectedExecutionHandler h = new ThreadPoolExecutor.DiscardOldestPolicy();
1187 >        final CountDownLatch done = new CountDownLatch(1);
1188 >        LatchAwaiter r1 = awaiter(done);
1189 >        LatchAwaiter r2 = awaiter(done);
1190 >        LatchAwaiter r3 = awaiter(done);
1191          final ThreadPoolExecutor p =
1192              new ThreadPoolExecutor(1, 1,
1193                                     LONG_DELAY_MS, MILLISECONDS,
1194                                     new ArrayBlockingQueue<Runnable>(1),
1195 <                                   h);
1196 <        try {
1197 <            p.execute(new TrackedLongRunnable());
1198 <            TrackedLongRunnable r2 = new TrackedLongRunnable();
1195 >                                   new ThreadPoolExecutor.DiscardOldestPolicy());
1196 >        try (PoolCleaner cleaner = cleaner(p)) {
1197 >            assertEquals(LatchAwaiter.NEW, r1.state);
1198 >            assertEquals(LatchAwaiter.NEW, r2.state);
1199 >            assertEquals(LatchAwaiter.NEW, r3.state);
1200 >            p.execute(r1);
1201              p.execute(r2);
1202              assertTrue(p.getQueue().contains(r2));
1198            TrackedNoOpRunnable r3 = new TrackedNoOpRunnable();
1203              p.execute(r3);
1204              assertFalse(p.getQueue().contains(r2));
1205              assertTrue(p.getQueue().contains(r3));
1206 <            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
1203 <        } finally {
1204 <            joinPool(p);
1206 >            done.countDown();
1207          }
1208 +        assertEquals(LatchAwaiter.DONE, r1.state);
1209 +        assertEquals(LatchAwaiter.NEW, r2.state);
1210 +        assertEquals(LatchAwaiter.DONE, r3.state);
1211      }
1212  
1213      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines