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

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.73 by jsr166, Sun Oct 4 02:49:18 2015 UTC vs.
Revision 1.74 by jsr166, Sun Oct 4 03:07:31 2015 UTC

# Line 1151 | Line 1151 | public class ThreadPoolExecutorSubclassT
1151       * executor using CallerRunsPolicy runs task if saturated.
1152       */
1153      public void testSaturatedExecute2() {
1154 <        RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
1155 <        ThreadPoolExecutor p = new CustomTPE(1, 1,
1156 <                                             LONG_DELAY_MS, MILLISECONDS,
1157 <                                             new ArrayBlockingQueue<Runnable>(1),
1158 <                                             h);
1159 <        try {
1154 >        final ThreadPoolExecutor p =
1155 >            new CustomTPE(1, 1,
1156 >                          LONG_DELAY_MS, MILLISECONDS,
1157 >                          new ArrayBlockingQueue<Runnable>(1),
1158 >                          new CustomTPE.CallerRunsPolicy());
1159 >        try (PoolCleaner cleaner = cleaner(p)) {
1160 >            final CountDownLatch done = new CountDownLatch(1);
1161 >            Runnable blocker = new CheckedRunnable() {
1162 >                public void realRun() throws InterruptedException {
1163 >                    done.await();
1164 >                }};
1165 >            p.execute(blocker);
1166              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
1167 <            for (int i = 0; i < tasks.length; ++i)
1167 >            for (int i = 0; i < tasks.length; i++)
1168                  tasks[i] = new TrackedNoOpRunnable();
1169 <            TrackedLongRunnable mr = new TrackedLongRunnable();
1164 <            p.execute(mr);
1165 <            for (int i = 0; i < tasks.length; ++i)
1169 >            for (int i = 0; i < tasks.length; i++)
1170                  p.execute(tasks[i]);
1171 <            for (int i = 1; i < tasks.length; ++i)
1171 >            for (int i = 1; i < tasks.length; i++)
1172                  assertTrue(tasks[i].done);
1173 <            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
1174 <        } finally {
1175 <            joinPool(p);
1173 >            // tasks[0] is waiting in queue
1174 >            assertFalse(tasks[0].done);
1175 >            done.countDown();
1176          }
1177      }
1178  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines