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.1 by dl, Fri May 20 16:30:17 2005 UTC vs.
Revision 1.15 by jsr166, Sat Nov 21 20:17:40 2009 UTC

# Line 2 | Line 2
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain
5 < * Other contributors include Andrew Wright, Jeffrey Hayes,
6 < * Pat Fisher, Mike Judd.
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import java.util.concurrent.*;
10 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
11   import java.util.concurrent.locks.*;
12  
13   import junit.framework.*;
# Line 14 | Line 15 | import java.util.*;
15  
16   public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
17      public static void main(String[] args) {
18 <        junit.textui.TestRunner.run (suite());  
18 >        junit.textui.TestRunner.run(suite());
19      }
20      public static Test suite() {
21 <        return new TestSuite(ThreadPoolExecutorTest.class);
21 >        return new TestSuite(ThreadPoolExecutorSubclassTest.class);
22      }
23  
24      static class CustomTask<V> implements RunnableFuture<V> {
# Line 29 | Line 30 | public class ThreadPoolExecutorSubclassT
30          V result;
31          Thread thread;
32          Exception exception;
33 <        CustomTask(Callable<V> c) { callable = c; }
34 <        CustomTask(final Runnable r, final V res) { callable = new Callable<V>() {
35 <            public V call() throws Exception { r.run(); return res; }};
33 >        CustomTask(Callable<V> c) {
34 >            if (c == null) throw new NullPointerException();
35 >            callable = c;
36 >        }
37 >        CustomTask(final Runnable r, final V res) {
38 >            if (r == null) throw new NullPointerException();
39 >            callable = new Callable<V>() {
40 >            public V call() throws Exception { r.run(); return res; }};
41          }
42          public boolean isDone() {
43              lock.lock(); try { return done; } finally { lock.unlock() ; }
# Line 45 | Line 51 | public class ThreadPoolExecutorSubclassT
51                  if (!done) {
52                      cancelled = true;
53                      done = true;
54 <                    if (mayInterrupt && thread != null)
54 >                    if (mayInterrupt && thread != null)
55                          thread.interrupt();
56                      return true;
57                  }
# Line 68 | Line 74 | public class ThreadPoolExecutorSubclassT
74              try {
75                  v = callable.call();
76              }
77 <            catch(Exception ex) {
77 >            catch (Exception ex) {
78                  e = ex;
79              }
80              lock.lock();
# Line 84 | Line 90 | public class ThreadPoolExecutorSubclassT
90          public V get() throws InterruptedException, ExecutionException {
91              lock.lock();
92              try {
93 <                while (!done)
93 >                while (!done)
94                      cond.await();
95                  if (exception != null)
96                      throw new ExecutionException(exception);
# Line 93 | Line 99 | public class ThreadPoolExecutorSubclassT
99              finally { lock.unlock(); }
100          }
101          public V get(long timeout, TimeUnit unit)
102 <            throws InterruptedException, ExecutionException, TimeoutException{
102 >            throws InterruptedException, ExecutionException, TimeoutException {
103              long nanos = unit.toNanos(timeout);
104              lock.lock();
105              try {
# Line 109 | Line 115 | public class ThreadPoolExecutorSubclassT
115              }
116              finally { lock.unlock(); }
117          }
118 <    }            
118 >    }
119 >
120  
114    
121      static class CustomTPE extends ThreadPoolExecutor {
122          protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
123              return new CustomTask<V>(c);
124          }
125          protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
126              return new CustomTask<V>(r, v);
127 <        }
128 <        
127 >        }
128 >
129          CustomTPE(int corePoolSize,
130                    int maximumPoolSize,
131                    long keepAliveTime,
132                    TimeUnit unit,
133                    BlockingQueue<Runnable> workQueue) {
134 <            super(corePoolSize, maximumPoolSize, keepAliveTime, unit,
134 >            super(corePoolSize, maximumPoolSize, keepAliveTime, unit,
135                    workQueue);
136          }
137          CustomTPE(int corePoolSize,
# Line 154 | Line 160 | public class ThreadPoolExecutorSubclassT
160                    BlockingQueue<Runnable> workQueue,
161                    ThreadFactory threadFactory,
162                    RejectedExecutionHandler handler) {
163 <            super(corePoolSize, maximumPoolSize, keepAliveTime, unit,
163 >            super(corePoolSize, maximumPoolSize, keepAliveTime, unit,
164                workQueue, threadFactory, handler);
165          }
166  
# Line 162 | Line 168 | public class ThreadPoolExecutorSubclassT
168          volatile boolean afterCalled = false;
169          volatile boolean terminatedCalled = false;
170          public CustomTPE() {
171 <            super(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>());
171 >            super(1, 1, LONG_DELAY_MS, MILLISECONDS, new SynchronousQueue<Runnable>());
172          }
173          protected void beforeExecute(Thread t, Runnable r) {
174              beforeCalled = true;
# Line 173 | Line 179 | public class ThreadPoolExecutorSubclassT
179          protected void terminated() {
180              terminatedCalled = true;
181          }
182 <        
182 >
183      }
184  
185 <    static class FailingThreadFactory implements ThreadFactory{
185 >    static class FailingThreadFactory implements ThreadFactory {
186          int calls = 0;
187 <        public Thread newThread(Runnable r){
187 >        public Thread newThread(Runnable r) {
188              if (++calls > 1) return null;
189              return new Thread(r);
190 <        }  
190 >        }
191      }
192 <    
192 >
193  
194      /**
195       *  execute successfully executes a runnable
196       */
197 <    public void testExecute() {
198 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
197 >    public void testExecute() throws InterruptedException {
198 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
199          try {
200 <            p1.execute(new Runnable() {
201 <                    public void run() {
202 <                        try {
203 <                            Thread.sleep(SHORT_DELAY_MS);
204 <                        } catch(InterruptedException e){
199 <                            threadUnexpectedException();
200 <                        }
201 <                    }
202 <                });
203 <            Thread.sleep(SMALL_DELAY_MS);
204 <        } catch(InterruptedException e){
205 <            unexpectedException();
206 <        }
207 <        joinPool(p1);
200 >            p1.execute(new ShortRunnable());
201 >            Thread.sleep(SMALL_DELAY_MS);
202 >        } finally {
203 >            joinPool(p1);
204 >        }
205      }
206  
207      /**
208       *  getActiveCount increases but doesn't overestimate, when a
209       *  thread becomes active
210       */
211 <    public void testGetActiveCount() {
212 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
211 >    public void testGetActiveCount() throws InterruptedException {
212 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
213          assertEquals(0, p2.getActiveCount());
214          p2.execute(new MediumRunnable());
215 <        try {
219 <            Thread.sleep(SHORT_DELAY_MS);
220 <        } catch(Exception e){
221 <            unexpectedException();
222 <        }
215 >        Thread.sleep(SHORT_DELAY_MS);
216          assertEquals(1, p2.getActiveCount());
217          joinPool(p2);
218      }
# Line 228 | Line 221 | public class ThreadPoolExecutorSubclassT
221       *  prestartCoreThread starts a thread if under corePoolSize, else doesn't
222       */
223      public void testPrestartCoreThread() {
224 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
224 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
225          assertEquals(0, p2.getPoolSize());
226          assertTrue(p2.prestartCoreThread());
227          assertEquals(1, p2.getPoolSize());
# Line 243 | Line 236 | public class ThreadPoolExecutorSubclassT
236       *  prestartAllCoreThreads starts all corePoolSize threads
237       */
238      public void testPrestartAllCoreThreads() {
239 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
239 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
240          assertEquals(0, p2.getPoolSize());
241          p2.prestartAllCoreThreads();
242          assertEquals(2, p2.getPoolSize());
# Line 251 | Line 244 | public class ThreadPoolExecutorSubclassT
244          assertEquals(2, p2.getPoolSize());
245          joinPool(p2);
246      }
247 <    
247 >
248      /**
249       *   getCompletedTaskCount increases, but doesn't overestimate,
250       *   when tasks complete
251       */
252 <    public void testGetCompletedTaskCount() {
253 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
252 >    public void testGetCompletedTaskCount() throws InterruptedException {
253 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
254          assertEquals(0, p2.getCompletedTaskCount());
255          p2.execute(new ShortRunnable());
256 <        try {
264 <            Thread.sleep(SMALL_DELAY_MS);
265 <        } catch(Exception e){
266 <            unexpectedException();
267 <        }
256 >        Thread.sleep(SMALL_DELAY_MS);
257          assertEquals(1, p2.getCompletedTaskCount());
258 <        try { p2.shutdown(); } catch(SecurityException ok) { return; }
258 >        try { p2.shutdown(); } catch (SecurityException ok) { return; }
259          joinPool(p2);
260      }
261 <    
261 >
262      /**
263       *   getCorePoolSize returns size given in constructor if not otherwise set
264       */
265      public void testGetCorePoolSize() {
266 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
266 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
267          assertEquals(1, p1.getCorePoolSize());
268          joinPool(p1);
269      }
270 <    
270 >
271      /**
272       *   getKeepAliveTime returns value given in constructor if not otherwise set
273       */
274      public void testGetKeepAliveTime() {
275 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
275 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
276          assertEquals(1, p2.getKeepAliveTime(TimeUnit.SECONDS));
277          joinPool(p2);
278      }
279  
280  
281 <    /**
281 >    /**
282       * getThreadFactory returns factory in constructor if not set
283       */
284      public void testGetThreadFactory() {
285          ThreadFactory tf = new SimpleThreadFactory();
286 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), tf, new NoOpREHandler());
286 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), tf, new NoOpREHandler());
287          assertSame(tf, p.getThreadFactory());
288          joinPool(p);
289      }
290  
291 <    /**
291 >    /**
292       * setThreadFactory sets the thread factory returned by getThreadFactory
293       */
294      public void testSetThreadFactory() {
295 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
295 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
296          ThreadFactory tf = new SimpleThreadFactory();
297          p.setThreadFactory(tf);
298          assertSame(tf, p.getThreadFactory());
# Line 311 | Line 300 | public class ThreadPoolExecutorSubclassT
300      }
301  
302  
303 <    /**
303 >    /**
304       * setThreadFactory(null) throws NPE
305       */
306      public void testSetThreadFactoryNull() {
307 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
307 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
308          try {
309              p.setThreadFactory(null);
310              shouldThrow();
# Line 325 | Line 314 | public class ThreadPoolExecutorSubclassT
314          }
315      }
316  
317 <    /**
317 >    /**
318       * getRejectedExecutionHandler returns handler in constructor if not set
319       */
320      public void testGetRejectedExecutionHandler() {
321          RejectedExecutionHandler h = new NoOpREHandler();
322 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
322 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
323          assertSame(h, p.getRejectedExecutionHandler());
324          joinPool(p);
325      }
326  
327 <    /**
327 >    /**
328       * setRejectedExecutionHandler sets the handler returned by
329       * getRejectedExecutionHandler
330       */
331      public void testSetRejectedExecutionHandler() {
332 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
332 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
333          RejectedExecutionHandler h = new NoOpREHandler();
334          p.setRejectedExecutionHandler(h);
335          assertSame(h, p.getRejectedExecutionHandler());
# Line 348 | Line 337 | public class ThreadPoolExecutorSubclassT
337      }
338  
339  
340 <    /**
340 >    /**
341       * setRejectedExecutionHandler(null) throws NPE
342       */
343      public void testSetRejectedExecutionHandlerNull() {
344 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
344 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
345          try {
346              p.setRejectedExecutionHandler(null);
347              shouldThrow();
# Line 362 | Line 351 | public class ThreadPoolExecutorSubclassT
351          }
352      }
353  
354 <    
354 >
355      /**
356       *   getLargestPoolSize increases, but doesn't overestimate, when
357       *   multiple threads active
358       */
359 <    public void testGetLargestPoolSize() {
360 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
361 <        try {
362 <            assertEquals(0, p2.getLargestPoolSize());
363 <            p2.execute(new MediumRunnable());
364 <            p2.execute(new MediumRunnable());
365 <            Thread.sleep(SHORT_DELAY_MS);
377 <            assertEquals(2, p2.getLargestPoolSize());
378 <        } catch(Exception e){
379 <            unexpectedException();
380 <        }
359 >    public void testGetLargestPoolSize() throws InterruptedException {
360 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
361 >        assertEquals(0, p2.getLargestPoolSize());
362 >        p2.execute(new MediumRunnable());
363 >        p2.execute(new MediumRunnable());
364 >        Thread.sleep(SHORT_DELAY_MS);
365 >        assertEquals(2, p2.getLargestPoolSize());
366          joinPool(p2);
367      }
368 <    
368 >
369      /**
370       *   getMaximumPoolSize returns value given in constructor if not
371       *   otherwise set
372       */
373      public void testGetMaximumPoolSize() {
374 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
374 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
375          assertEquals(2, p2.getMaximumPoolSize());
376          joinPool(p2);
377      }
378 <    
378 >
379      /**
380       *   getPoolSize increases, but doesn't overestimate, when threads
381       *   become active
382       */
383      public void testGetPoolSize() {
384 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
384 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
385          assertEquals(0, p1.getPoolSize());
386          p1.execute(new MediumRunnable());
387          assertEquals(1, p1.getPoolSize());
388          joinPool(p1);
389      }
390 <    
390 >
391      /**
392       *  getTaskCount increases, but doesn't overestimate, when tasks submitted
393       */
394 <    public void testGetTaskCount() {
395 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
396 <        try {
397 <            assertEquals(0, p1.getTaskCount());
398 <            p1.execute(new MediumRunnable());
399 <            Thread.sleep(SHORT_DELAY_MS);
415 <            assertEquals(1, p1.getTaskCount());
416 <        } catch(Exception e){
417 <            unexpectedException();
418 <        }
394 >    public void testGetTaskCount() throws InterruptedException {
395 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
396 >        assertEquals(0, p1.getTaskCount());
397 >        p1.execute(new MediumRunnable());
398 >        Thread.sleep(SHORT_DELAY_MS);
399 >        assertEquals(1, p1.getTaskCount());
400          joinPool(p1);
401      }
402 <    
402 >
403      /**
404       *   isShutDown is false before shutdown, true after
405       */
406      public void testIsShutdown() {
407 <        
408 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
407 >
408 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
409          assertFalse(p1.isShutdown());
410 <        try { p1.shutdown(); } catch(SecurityException ok) { return; }
411 <        assertTrue(p1.isShutdown());
410 >        try { p1.shutdown(); } catch (SecurityException ok) { return; }
411 >        assertTrue(p1.isShutdown());
412          joinPool(p1);
413      }
414  
415 <        
415 >
416      /**
417       *  isTerminated is false before termination, true after
418       */
419 <    public void testIsTerminated() {
420 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
419 >    public void testIsTerminated() throws InterruptedException {
420 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
421          assertFalse(p1.isTerminated());
422          try {
423              p1.execute(new MediumRunnable());
424          } finally {
425 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
425 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
426          }
427 <        try {
428 <            assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
448 <            assertTrue(p1.isTerminated());
449 <        } catch(Exception e){
450 <            unexpectedException();
451 <        }      
427 >        assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
428 >        assertTrue(p1.isTerminated());
429      }
430  
431      /**
432       *  isTerminating is not true when running or when terminated
433       */
434 <    public void testIsTerminating() {
435 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
434 >    public void testIsTerminating() throws InterruptedException {
435 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
436          assertFalse(p1.isTerminating());
437          try {
438              p1.execute(new SmallRunnable());
439              assertFalse(p1.isTerminating());
440          } finally {
441 <            try { p1.shutdown(); } catch(SecurityException ok) { return; }
441 >            try { p1.shutdown(); } catch (SecurityException ok) { return; }
442          }
443 <        try {
444 <            assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
445 <            assertTrue(p1.isTerminated());
469 <            assertFalse(p1.isTerminating());
470 <        } catch(Exception e){
471 <            unexpectedException();
472 <        }      
443 >        assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
444 >        assertTrue(p1.isTerminated());
445 >        assertFalse(p1.isTerminating());
446      }
447  
448      /**
449       * getQueue returns the work queue, which contains queued tasks
450       */
451 <    public void testGetQueue() {
451 >    public void testGetQueue() throws InterruptedException {
452          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
453 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
453 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q);
454          FutureTask[] tasks = new FutureTask[5];
455 <        for(int i = 0; i < 5; i++){
455 >        for (int i = 0; i < 5; i++) {
456              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
457              p1.execute(tasks[i]);
458          }
# Line 492 | Line 465 | public class ThreadPoolExecutorSubclassT
465              for (int i = 1; i < 5; ++i)
466                  tasks[i].cancel(true);
467              p1.shutdownNow();
495        } catch(Exception e) {
496            unexpectedException();
468          } finally {
469              joinPool(p1);
470          }
# Line 502 | Line 473 | public class ThreadPoolExecutorSubclassT
473      /**
474       * remove(task) removes queued task, and fails to remove active task
475       */
476 <    public void testRemove() {
476 >    public void testRemove() throws InterruptedException {
477          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
478 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
478 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q);
479          FutureTask[] tasks = new FutureTask[5];
480 <        for(int i = 0; i < 5; i++){
480 >        for (int i = 0; i < 5; i++) {
481              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
482              p1.execute(tasks[i]);
483          }
# Line 521 | Line 492 | public class ThreadPoolExecutorSubclassT
492              assertTrue(q.contains(tasks[3]));
493              assertTrue(p1.remove(tasks[3]));
494              assertFalse(q.contains(tasks[3]));
524        } catch(Exception e) {
525            unexpectedException();
495          } finally {
496              joinPool(p1);
497          }
# Line 532 | Line 501 | public class ThreadPoolExecutorSubclassT
501       *   purge removes cancelled tasks from the queue
502       */
503      public void testPurge() {
504 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
504 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
505          FutureTask[] tasks = new FutureTask[5];
506 <        for(int i = 0; i < 5; i++){
506 >        for (int i = 0; i < 5; i++) {
507              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
508              p1.execute(tasks[i]);
509          }
# Line 550 | Line 519 | public class ThreadPoolExecutorSubclassT
519       *  shutDownNow returns a list containing tasks that were not run
520       */
521      public void testShutDownNow() {
522 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
522 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
523          List l;
524          try {
525 <            for(int i = 0; i < 5; i++)
525 >            for (int i = 0; i < 5; i++)
526                  p1.execute(new MediumPossiblyInterruptedRunnable());
527          }
528          finally {
529              try {
530                  l = p1.shutdownNow();
531              } catch (SecurityException ok) { return; }
532 <            
532 >
533          }
534 <        assertTrue(p1.isShutdown());
535 <        assertTrue(l.size() <= 4);
534 >        assertTrue(p1.isShutdown());
535 >        assertTrue(l.size() <= 4);
536      }
537  
538      // Exception Tests
570    
539  
540 <    /**
541 <     * Constructor throws if corePoolSize argument is less than zero
540 >
541 >    /**
542 >     * Constructor throws if corePoolSize argument is less than zero
543       */
544      public void testConstructor1() {
545          try {
546 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
546 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
547              shouldThrow();
548 <        }
580 <        catch (IllegalArgumentException success){}
548 >        } catch (IllegalArgumentException success) {}
549      }
550 <    
551 <    /**
552 <     * Constructor throws if maximumPoolSize is less than zero
550 >
551 >    /**
552 >     * Constructor throws if maximumPoolSize is less than zero
553       */
554      public void testConstructor2() {
555          try {
556 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
556 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
557              shouldThrow();
558 <        }
591 <        catch (IllegalArgumentException success){}
558 >        } catch (IllegalArgumentException success) {}
559      }
560 <    
561 <    /**
562 <     * Constructor throws if maximumPoolSize is equal to zero
560 >
561 >    /**
562 >     * Constructor throws if maximumPoolSize is equal to zero
563       */
564      public void testConstructor3() {
565          try {
566 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
566 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
567              shouldThrow();
568 <        }
602 <        catch (IllegalArgumentException success){}
568 >        } catch (IllegalArgumentException success) {}
569      }
570  
571 <    /**
572 <     * Constructor throws if keepAliveTime is less than zero
571 >    /**
572 >     * Constructor throws if keepAliveTime is less than zero
573       */
574      public void testConstructor4() {
575          try {
576 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
576 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
577              shouldThrow();
578 <        }
613 <        catch (IllegalArgumentException success){}
578 >        } catch (IllegalArgumentException success) {}
579      }
580  
581 <    /**
582 <     * Constructor throws if corePoolSize is greater than the maximumPoolSize
581 >    /**
582 >     * Constructor throws if corePoolSize is greater than the maximumPoolSize
583       */
584      public void testConstructor5() {
585          try {
586 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
586 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
587              shouldThrow();
588 <        }
624 <        catch (IllegalArgumentException success){}
588 >        } catch (IllegalArgumentException success) {}
589      }
590 <        
591 <    /**
592 <     * Constructor throws if workQueue is set to null
590 >
591 >    /**
592 >     * Constructor throws if workQueue is set to null
593       */
594      public void testConstructorNullPointerException() {
595          try {
596 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null);
596 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null);
597              shouldThrow();
598 <        }
635 <        catch (NullPointerException success){}  
598 >        } catch (NullPointerException success) {}
599      }
637    
600  
601 <    
602 <    /**
603 <     * Constructor throws if corePoolSize argument is less than zero
601 >
602 >
603 >    /**
604 >     * Constructor throws if corePoolSize argument is less than zero
605       */
606      public void testConstructor6() {
607          try {
608 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
608 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
609              shouldThrow();
610 <        } catch (IllegalArgumentException success){}
610 >        } catch (IllegalArgumentException success) {}
611      }
612 <    
613 <    /**
614 <     * Constructor throws if maximumPoolSize is less than zero
612 >
613 >    /**
614 >     * Constructor throws if maximumPoolSize is less than zero
615       */
616      public void testConstructor7() {
617          try {
618 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
618 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
619              shouldThrow();
620 <        }
658 <        catch (IllegalArgumentException success){}
620 >        } catch (IllegalArgumentException success) {}
621      }
622  
623 <    /**
624 <     * Constructor throws if maximumPoolSize is equal to zero
623 >    /**
624 >     * Constructor throws if maximumPoolSize is equal to zero
625       */
626      public void testConstructor8() {
627          try {
628 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
628 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
629              shouldThrow();
630 <        }
669 <        catch (IllegalArgumentException success){}
630 >        } catch (IllegalArgumentException success) {}
631      }
632  
633 <    /**
634 <     * Constructor throws if keepAliveTime is less than zero
633 >    /**
634 >     * Constructor throws if keepAliveTime is less than zero
635       */
636      public void testConstructor9() {
637          try {
638 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
638 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
639              shouldThrow();
640 <        }
680 <        catch (IllegalArgumentException success){}
640 >        } catch (IllegalArgumentException success) {}
641      }
642  
643 <    /**
644 <     * Constructor throws if corePoolSize is greater than the maximumPoolSize
643 >    /**
644 >     * Constructor throws if corePoolSize is greater than the maximumPoolSize
645       */
646      public void testConstructor10() {
647          try {
648 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
648 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
649              shouldThrow();
650 <        }
691 <        catch (IllegalArgumentException success){}
650 >        } catch (IllegalArgumentException success) {}
651      }
652  
653 <    /**
654 <     * Constructor throws if workQueue is set to null
653 >    /**
654 >     * Constructor throws if workQueue is set to null
655       */
656      public void testConstructorNullPointerException2() {
657          try {
658 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory());
658 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory());
659              shouldThrow();
660 <        }
702 <        catch (NullPointerException success){}  
660 >        } catch (NullPointerException success) {}
661      }
662  
663 <    /**
664 <     * Constructor throws if threadFactory is set to null
663 >    /**
664 >     * Constructor throws if threadFactory is set to null
665       */
666      public void testConstructorNullPointerException3() {
667          try {
668              ThreadFactory f = null;
669 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f);
669 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f);
670              shouldThrow();
671 <        }
714 <        catch (NullPointerException success){}  
671 >        } catch (NullPointerException success) {}
672      }
673 <
674 <    
675 <    /**
676 <     * Constructor throws if corePoolSize argument is less than zero
673 >
674 >
675 >    /**
676 >     * Constructor throws if corePoolSize argument is less than zero
677       */
678      public void testConstructor11() {
679          try {
680 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
680 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
681              shouldThrow();
682 <        }
726 <        catch (IllegalArgumentException success){}
682 >        } catch (IllegalArgumentException success) {}
683      }
684  
685 <    /**
686 <     * Constructor throws if maximumPoolSize is less than zero
685 >    /**
686 >     * Constructor throws if maximumPoolSize is less than zero
687       */
688      public void testConstructor12() {
689          try {
690 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
690 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
691              shouldThrow();
692 <        }
737 <        catch (IllegalArgumentException success){}
692 >        } catch (IllegalArgumentException success) {}
693      }
694  
695 <    /**
696 <     * Constructor throws if maximumPoolSize is equal to zero
695 >    /**
696 >     * Constructor throws if maximumPoolSize is equal to zero
697       */
698      public void testConstructor13() {
699          try {
700 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
700 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
701              shouldThrow();
702 <        }
748 <        catch (IllegalArgumentException success){}
702 >        } catch (IllegalArgumentException success) {}
703      }
704  
705 <    /**
706 <     * Constructor throws if keepAliveTime is less than zero
705 >    /**
706 >     * Constructor throws if keepAliveTime is less than zero
707       */
708      public void testConstructor14() {
709          try {
710 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
710 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
711              shouldThrow();
712 <        }
759 <        catch (IllegalArgumentException success){}
712 >        } catch (IllegalArgumentException success) {}
713      }
714  
715 <    /**
716 <     * Constructor throws if corePoolSize is greater than the maximumPoolSize
715 >    /**
716 >     * Constructor throws if corePoolSize is greater than the maximumPoolSize
717       */
718      public void testConstructor15() {
719          try {
720 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
720 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
721              shouldThrow();
722 <        }
770 <        catch (IllegalArgumentException success){}
722 >        } catch (IllegalArgumentException success) {}
723      }
724  
725 <    /**
726 <     * Constructor throws if workQueue is set to null
725 >    /**
726 >     * Constructor throws if workQueue is set to null
727       */
728      public void testConstructorNullPointerException4() {
729          try {
730 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler());
730 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new NoOpREHandler());
731              shouldThrow();
732 <        }
781 <        catch (NullPointerException success){}  
732 >        } catch (NullPointerException success) {}
733      }
734  
735 <    /**
736 <     * Constructor throws if handler is set to null
735 >    /**
736 >     * Constructor throws if handler is set to null
737       */
738      public void testConstructorNullPointerException5() {
739          try {
740              RejectedExecutionHandler r = null;
741 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r);
741 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r);
742              shouldThrow();
743 <        }
793 <        catch (NullPointerException success){}  
743 >        } catch (NullPointerException success) {}
744      }
745  
746 <    
747 <    /**
748 <     * Constructor throws if corePoolSize argument is less than zero
746 >
747 >    /**
748 >     * Constructor throws if corePoolSize argument is less than zero
749       */
750      public void testConstructor16() {
751          try {
752 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
752 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
753              shouldThrow();
754 <        }
805 <        catch (IllegalArgumentException success){}
754 >        } catch (IllegalArgumentException success) {}
755      }
756  
757 <    /**
758 <     * Constructor throws if maximumPoolSize is less than zero
757 >    /**
758 >     * Constructor throws if maximumPoolSize is less than zero
759       */
760      public void testConstructor17() {
761          try {
762 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
762 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
763              shouldThrow();
764 <        }
816 <        catch (IllegalArgumentException success){}
764 >        } catch (IllegalArgumentException success) {}
765      }
766  
767 <    /**
768 <     * Constructor throws if maximumPoolSize is equal to zero
767 >    /**
768 >     * Constructor throws if maximumPoolSize is equal to zero
769       */
770      public void testConstructor18() {
771          try {
772 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
772 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
773              shouldThrow();
774 <        }
827 <        catch (IllegalArgumentException success){}
774 >        } catch (IllegalArgumentException success) {}
775      }
776  
777 <    /**
778 <     * Constructor throws if keepAliveTime is less than zero
777 >    /**
778 >     * Constructor throws if keepAliveTime is less than zero
779       */
780      public void testConstructor19() {
781          try {
782 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
782 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
783              shouldThrow();
784 <        }
838 <        catch (IllegalArgumentException success){}
784 >        } catch (IllegalArgumentException success) {}
785      }
786  
787 <    /**
788 <     * Constructor throws if corePoolSize is greater than the maximumPoolSize
787 >    /**
788 >     * Constructor throws if corePoolSize is greater than the maximumPoolSize
789       */
790      public void testConstructor20() {
791          try {
792 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
792 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
793              shouldThrow();
794 <        }
849 <        catch (IllegalArgumentException success){}
794 >        } catch (IllegalArgumentException success) {}
795      }
796  
797 <    /**
798 <     * Constructor throws if workQueue is set to null
797 >    /**
798 >     * Constructor throws if workQueue is set to null
799       */
800      public void testConstructorNullPointerException6() {
801          try {
802 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler());
802 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler());
803              shouldThrow();
804 <        }
860 <        catch (NullPointerException success){}  
804 >        } catch (NullPointerException success) {}
805      }
806  
807 <    /**
808 <     * Constructor throws if handler is set to null
807 >    /**
808 >     * Constructor throws if handler is set to null
809       */
810      public void testConstructorNullPointerException7() {
811          try {
812              RejectedExecutionHandler r = null;
813 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r);
813 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r);
814              shouldThrow();
815 <        }
872 <        catch (NullPointerException success){}  
815 >        } catch (NullPointerException success) {}
816      }
817  
818 <    /**
819 <     * Constructor throws if ThreadFactory is set top null
818 >    /**
819 >     * Constructor throws if ThreadFactory is set top null
820       */
821      public void testConstructorNullPointerException8() {
822          try {
823              ThreadFactory f = null;
824 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler());
824 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler());
825              shouldThrow();
826 <        }
884 <        catch (NullPointerException successdn8){}  
826 >        } catch (NullPointerException success) {}
827      }
828 <    
828 >
829  
830      /**
831       *  execute throws RejectedExecutionException
832       *  if saturated.
833       */
834      public void testSaturatedExecute() {
835 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
835 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
836          try {
837 <            
838 <            for(int i = 0; i < 5; ++i){
837 >
838 >            for (int i = 0; i < 5; ++i) {
839                  p.execute(new MediumRunnable());
840              }
841              shouldThrow();
842 <        } catch(RejectedExecutionException success){}
842 >        } catch (RejectedExecutionException success) {}
843          joinPool(p);
844      }
845  
# Line 906 | Line 848 | public class ThreadPoolExecutorSubclassT
848       */
849      public void testSaturatedExecute2() {
850          RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
851 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
851 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
852          try {
853 <            
853 >
854              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
855 <            for(int i = 0; i < 5; ++i){
855 >            for (int i = 0; i < 5; ++i) {
856                  tasks[i] = new TrackedNoOpRunnable();
857              }
858              TrackedLongRunnable mr = new TrackedLongRunnable();
859              p.execute(mr);
860 <            for(int i = 0; i < 5; ++i){
860 >            for (int i = 0; i < 5; ++i) {
861                  p.execute(tasks[i]);
862              }
863 <            for(int i = 1; i < 5; ++i) {
863 >            for (int i = 1; i < 5; ++i) {
864                  assertTrue(tasks[i].done);
865              }
866 <            try { p.shutdownNow(); } catch(SecurityException ok) { return; }
925 <        } catch(RejectedExecutionException ex){
926 <            unexpectedException();
866 >            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
867          } finally {
868              joinPool(p);
869          }
# Line 934 | Line 874 | public class ThreadPoolExecutorSubclassT
874       */
875      public void testSaturatedExecute3() {
876          RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
877 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
877 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
878          try {
879 <            
879 >
880              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
881 <            for(int i = 0; i < 5; ++i){
881 >            for (int i = 0; i < 5; ++i) {
882                  tasks[i] = new TrackedNoOpRunnable();
883              }
884              p.execute(new TrackedLongRunnable());
885 <            for(int i = 0; i < 5; ++i){
885 >            for (int i = 0; i < 5; ++i) {
886                  p.execute(tasks[i]);
887              }
888 <            for(int i = 0; i < 5; ++i){
888 >            for (int i = 0; i < 5; ++i) {
889                  assertFalse(tasks[i].done);
890              }
891 <            try { p.shutdownNow(); } catch(SecurityException ok) { return; }
952 <        } catch(RejectedExecutionException ex){
953 <            unexpectedException();
891 >            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
892          } finally {
893              joinPool(p);
894          }
# Line 961 | Line 899 | public class ThreadPoolExecutorSubclassT
899       */
900      public void testSaturatedExecute4() {
901          RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
902 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
902 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
903          try {
904              p.execute(new TrackedLongRunnable());
905              TrackedLongRunnable r2 = new TrackedLongRunnable();
# Line 971 | Line 909 | public class ThreadPoolExecutorSubclassT
909              p.execute(r3);
910              assertFalse(p.getQueue().contains(r2));
911              assertTrue(p.getQueue().contains(r3));
912 <            try { p.shutdownNow(); } catch(SecurityException ok) { return; }
975 <        } catch(RejectedExecutionException ex){
976 <            unexpectedException();
912 >            try { p.shutdownNow(); } catch (SecurityException ok) { return; }
913          } finally {
914              joinPool(p);
915          }
# Line 983 | Line 919 | public class ThreadPoolExecutorSubclassT
919       *  execute throws RejectedExecutionException if shutdown
920       */
921      public void testRejectedExecutionExceptionOnShutdown() {
922 <        ThreadPoolExecutor tpe =
923 <            new CustomTPE(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
924 <        try { tpe.shutdown(); } catch(SecurityException ok) { return; }
925 <        try {
926 <            tpe.execute(new NoOpRunnable());
927 <            shouldThrow();
928 <        } catch(RejectedExecutionException success){}
929 <        
930 <        joinPool(tpe);
922 >        ThreadPoolExecutor tpe =
923 >            new CustomTPE(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
924 >        try { tpe.shutdown(); } catch (SecurityException ok) { return; }
925 >        try {
926 >            tpe.execute(new NoOpRunnable());
927 >            shouldThrow();
928 >        } catch (RejectedExecutionException success) {}
929 >
930 >        joinPool(tpe);
931      }
932  
933      /**
# Line 999 | Line 935 | public class ThreadPoolExecutorSubclassT
935       */
936      public void testCallerRunsOnShutdown() {
937          RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
938 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
938 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
939  
940 <        try { p.shutdown(); } catch(SecurityException ok) { return; }
941 <        try {
940 >        try { p.shutdown(); } catch (SecurityException ok) { return; }
941 >        try {
942              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
943 <            p.execute(r);
943 >            p.execute(r);
944              assertFalse(r.done);
1009        } catch(RejectedExecutionException success){
1010            unexpectedException();
945          } finally {
946              joinPool(p);
947          }
# Line 1018 | Line 952 | public class ThreadPoolExecutorSubclassT
952       */
953      public void testDiscardOnShutdown() {
954          RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
955 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
955 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
956  
957 <        try { p.shutdown(); } catch(SecurityException ok) { return; }
958 <        try {
957 >        try { p.shutdown(); } catch (SecurityException ok) { return; }
958 >        try {
959              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
960 <            p.execute(r);
960 >            p.execute(r);
961              assertFalse(r.done);
1028        } catch(RejectedExecutionException success){
1029            unexpectedException();
962          } finally {
963              joinPool(p);
964          }
# Line 1038 | Line 970 | public class ThreadPoolExecutorSubclassT
970       */
971      public void testDiscardOldestOnShutdown() {
972          RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
973 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
973 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
974  
975 <        try { p.shutdown(); } catch(SecurityException ok) { return; }
976 <        try {
975 >        try { p.shutdown(); } catch (SecurityException ok) { return; }
976 >        try {
977              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
978 <            p.execute(r);
978 >            p.execute(r);
979              assertFalse(r.done);
1048        } catch(RejectedExecutionException success){
1049            unexpectedException();
980          } finally {
981              joinPool(p);
982          }
# Line 1059 | Line 989 | public class ThreadPoolExecutorSubclassT
989      public void testExecuteNull() {
990          ThreadPoolExecutor tpe = null;
991          try {
992 <            tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
993 <            tpe.execute(null);
992 >            tpe = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
993 >            tpe.execute(null);
994              shouldThrow();
995 <        } catch(NullPointerException success){}
996 <        
997 <        joinPool(tpe);
995 >        } catch (NullPointerException success) {}
996 >
997 >        joinPool(tpe);
998      }
999 <    
999 >
1000      /**
1001       *  setCorePoolSize of negative value throws IllegalArgumentException
1002       */
1003      public void testCorePoolSizeIllegalArgumentException() {
1004 <        ThreadPoolExecutor tpe = null;
1005 <        try {
1006 <            tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1007 <        } catch(Exception e){}
1008 <        try {
1009 <            tpe.setCorePoolSize(-1);
1080 <            shouldThrow();
1081 <        } catch(IllegalArgumentException success){
1004 >        ThreadPoolExecutor tpe =
1005 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1006 >        try {
1007 >            tpe.setCorePoolSize(-1);
1008 >            shouldThrow();
1009 >        } catch (IllegalArgumentException success) {
1010          } finally {
1011 <            try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1011 >            try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1012          }
1013          joinPool(tpe);
1014 <    }  
1014 >    }
1015  
1016      /**
1017       *  setMaximumPoolSize(int) throws IllegalArgumentException if
1018       *  given a value less the core pool size
1019 <     */  
1019 >     */
1020      public void testMaximumPoolSizeIllegalArgumentException() {
1021 <        ThreadPoolExecutor tpe = null;
1022 <        try {
1095 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1096 <        } catch(Exception e){}
1021 >        ThreadPoolExecutor tpe =
1022 >            new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1023          try {
1024              tpe.setMaximumPoolSize(1);
1025              shouldThrow();
1026 <        } catch(IllegalArgumentException success){
1026 >        } catch (IllegalArgumentException success) {
1027          } finally {
1028 <            try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1028 >            try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1029          }
1030          joinPool(tpe);
1031      }
1032 <    
1032 >
1033      /**
1034       *  setMaximumPoolSize throws IllegalArgumentException
1035       *  if given a negative value
1036       */
1037      public void testMaximumPoolSizeIllegalArgumentException2() {
1038 <        ThreadPoolExecutor tpe = null;
1039 <        try {
1114 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1115 <        } catch(Exception e){}
1038 >        ThreadPoolExecutor tpe =
1039 >            new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1040          try {
1041              tpe.setMaximumPoolSize(-1);
1042              shouldThrow();
1043 <        } catch(IllegalArgumentException success){
1043 >        } catch (IllegalArgumentException success) {
1044          } finally {
1045 <            try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1045 >            try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1046          }
1047          joinPool(tpe);
1048      }
1049 <    
1049 >
1050  
1051      /**
1052       *  setKeepAliveTime  throws IllegalArgumentException
1053       *  when given a negative value
1054       */
1055      public void testKeepAliveTimeIllegalArgumentException() {
1056 <        ThreadPoolExecutor tpe = null;
1056 >        ThreadPoolExecutor tpe =
1057 >            new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1058 >
1059          try {
1060 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1135 <        } catch(Exception e){}
1136 <        
1137 <        try {
1138 <            tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS);
1060 >            tpe.setKeepAliveTime(-1,MILLISECONDS);
1061              shouldThrow();
1062 <        } catch(IllegalArgumentException success){
1062 >        } catch (IllegalArgumentException success) {
1063          } finally {
1064 <            try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1064 >            try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1065          }
1066          joinPool(tpe);
1067      }
# Line 1149 | Line 1071 | public class ThreadPoolExecutorSubclassT
1071       */
1072      public void testTerminated() {
1073          CustomTPE tpe = new CustomTPE();
1074 <        try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1074 >        try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1075          assertTrue(tpe.terminatedCalled);
1076          joinPool(tpe);
1077      }
# Line 1157 | Line 1079 | public class ThreadPoolExecutorSubclassT
1079      /**
1080       * beforeExecute and afterExecute are called when executing task
1081       */
1082 <    public void testBeforeAfter() {
1082 >    public void testBeforeAfter() throws InterruptedException {
1083          CustomTPE tpe = new CustomTPE();
1084          try {
1085              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
# Line 1166 | Line 1088 | public class ThreadPoolExecutorSubclassT
1088              assertTrue(r.done);
1089              assertTrue(tpe.beforeCalled);
1090              assertTrue(tpe.afterCalled);
1091 <            try { tpe.shutdown(); } catch(SecurityException ok) { return; }
1170 <        }
1171 <        catch(Exception ex) {
1172 <            unexpectedException();
1091 >            try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1092          } finally {
1093              joinPool(tpe);
1094          }
# Line 1178 | Line 1097 | public class ThreadPoolExecutorSubclassT
1097      /**
1098       * completed submit of callable returns result
1099       */
1100 <    public void testSubmitCallable() {
1101 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1100 >    public void testSubmitCallable() throws Exception {
1101 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1102          try {
1103              Future<String> future = e.submit(new StringTask());
1104              String result = future.get();
1105              assertSame(TEST_STRING, result);
1187        }
1188        catch (ExecutionException ex) {
1189            unexpectedException();
1190        }
1191        catch (InterruptedException ex) {
1192            unexpectedException();
1106          } finally {
1107              joinPool(e);
1108          }
# Line 1198 | Line 1111 | public class ThreadPoolExecutorSubclassT
1111      /**
1112       * completed submit of runnable returns successfully
1113       */
1114 <    public void testSubmitRunnable() {
1115 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1114 >    public void testSubmitRunnable() throws Exception {
1115 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1116          try {
1117              Future<?> future = e.submit(new NoOpRunnable());
1118              future.get();
1119              assertTrue(future.isDone());
1207        }
1208        catch (ExecutionException ex) {
1209            unexpectedException();
1210        }
1211        catch (InterruptedException ex) {
1212            unexpectedException();
1120          } finally {
1121              joinPool(e);
1122          }
# Line 1218 | Line 1125 | public class ThreadPoolExecutorSubclassT
1125      /**
1126       * completed submit of (runnable, result) returns result
1127       */
1128 <    public void testSubmitRunnable2() {
1129 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1128 >    public void testSubmitRunnable2() throws Exception {
1129 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1130          try {
1131              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
1132              String result = future.get();
1133              assertSame(TEST_STRING, result);
1227        }
1228        catch (ExecutionException ex) {
1229            unexpectedException();
1230        }
1231        catch (InterruptedException ex) {
1232            unexpectedException();
1134          } finally {
1135              joinPool(e);
1136          }
1137      }
1138  
1139  
1239
1240
1241
1140      /**
1141       * invokeAny(null) throws NPE
1142       */
1143 <    public void testInvokeAny1() {
1144 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1143 >    public void testInvokeAny1() throws Exception {
1144 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1145          try {
1146              e.invokeAny(null);
1147 +            shouldThrow();
1148          } catch (NullPointerException success) {
1250        } catch(Exception ex) {
1251            unexpectedException();
1149          } finally {
1150              joinPool(e);
1151          }
# Line 1257 | Line 1154 | public class ThreadPoolExecutorSubclassT
1154      /**
1155       * invokeAny(empty collection) throws IAE
1156       */
1157 <    public void testInvokeAny2() {
1158 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1157 >    public void testInvokeAny2() throws Exception {
1158 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1159          try {
1160              e.invokeAny(new ArrayList<Callable<String>>());
1161 +            shouldThrow();
1162          } catch (IllegalArgumentException success) {
1265        } catch(Exception ex) {
1266            unexpectedException();
1163          } finally {
1164              joinPool(e);
1165          }
# Line 1272 | Line 1168 | public class ThreadPoolExecutorSubclassT
1168      /**
1169       * invokeAny(c) throws NPE if c has null elements
1170       */
1171 <    public void testInvokeAny3() {
1172 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1171 >    public void testInvokeAny3() throws Exception {
1172 >        final CountDownLatch latch = new CountDownLatch(1);
1173 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1174          try {
1175              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1176 <            l.add(new StringTask());
1176 >            l.add(new Callable<String>() {
1177 >                      public String call() {
1178 >                          try {
1179 >                              latch.await();
1180 >                          } catch (InterruptedException ok) {}
1181 >                          return TEST_STRING;
1182 >                      }});
1183              l.add(null);
1184              e.invokeAny(l);
1185 +            shouldThrow();
1186          } catch (NullPointerException success) {
1283        } catch(Exception ex) {
1284            unexpectedException();
1187          } finally {
1188 +            latch.countDown();
1189              joinPool(e);
1190          }
1191      }
# Line 1290 | Line 1193 | public class ThreadPoolExecutorSubclassT
1193      /**
1194       * invokeAny(c) throws ExecutionException if no task completes
1195       */
1196 <    public void testInvokeAny4() {
1197 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1196 >    public void testInvokeAny4() throws Exception {
1197 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1198          try {
1199              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1200              l.add(new NPETask());
1201              e.invokeAny(l);
1202 +            shouldThrow();
1203          } catch (ExecutionException success) {
1204 <        } catch(Exception ex) {
1301 <            unexpectedException();
1204 >            assertTrue(success.getCause() instanceof NullPointerException);
1205          } finally {
1206              joinPool(e);
1207          }
# Line 1307 | Line 1210 | public class ThreadPoolExecutorSubclassT
1210      /**
1211       * invokeAny(c) returns result of some task
1212       */
1213 <    public void testInvokeAny5() {
1214 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1213 >    public void testInvokeAny5() throws Exception {
1214 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1215          try {
1216              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1217              l.add(new StringTask());
1218              l.add(new StringTask());
1219              String result = e.invokeAny(l);
1220              assertSame(TEST_STRING, result);
1318        } catch (ExecutionException success) {
1319        } catch(Exception ex) {
1320            unexpectedException();
1221          } finally {
1222              joinPool(e);
1223          }
# Line 1326 | Line 1226 | public class ThreadPoolExecutorSubclassT
1226      /**
1227       * invokeAll(null) throws NPE
1228       */
1229 <    public void testInvokeAll1() {
1230 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1229 >    public void testInvokeAll1() throws Exception {
1230 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1231          try {
1232              e.invokeAll(null);
1233 +            shouldThrow();
1234          } catch (NullPointerException success) {
1334        } catch(Exception ex) {
1335            unexpectedException();
1235          } finally {
1236              joinPool(e);
1237          }
# Line 1341 | Line 1240 | public class ThreadPoolExecutorSubclassT
1240      /**
1241       * invokeAll(empty collection) returns empty collection
1242       */
1243 <    public void testInvokeAll2() {
1244 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1243 >    public void testInvokeAll2() throws Exception {
1244 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1245          try {
1246              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1247              assertTrue(r.isEmpty());
1349        } catch(Exception ex) {
1350            unexpectedException();
1248          } finally {
1249              joinPool(e);
1250          }
# Line 1356 | Line 1253 | public class ThreadPoolExecutorSubclassT
1253      /**
1254       * invokeAll(c) throws NPE if c has null elements
1255       */
1256 <    public void testInvokeAll3() {
1257 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1256 >    public void testInvokeAll3() throws Exception {
1257 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1258          try {
1259              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1260              l.add(new StringTask());
1261              l.add(null);
1262              e.invokeAll(l);
1263 +            shouldThrow();
1264          } catch (NullPointerException success) {
1367        } catch(Exception ex) {
1368            unexpectedException();
1265          } finally {
1266              joinPool(e);
1267          }
# Line 1374 | Line 1270 | public class ThreadPoolExecutorSubclassT
1270      /**
1271       * get of element of invokeAll(c) throws exception on failed task
1272       */
1273 <    public void testInvokeAll4() {
1274 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1273 >    public void testInvokeAll4() throws Exception {
1274 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1275          try {
1276              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1277              l.add(new NPETask());
1278              List<Future<String>> result = e.invokeAll(l);
1279              assertEquals(1, result.size());
1280 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1281 <                it.next().get();
1282 <        } catch(ExecutionException success) {
1283 <        } catch(Exception ex) {
1284 <            unexpectedException();
1280 >            for (Future<String> future : result)
1281 >                future.get();
1282 >            shouldThrow();
1283 >        } catch (ExecutionException success) {
1284 >            assertTrue(success.getCause() instanceof NullPointerException);
1285          } finally {
1286              joinPool(e);
1287          }
# Line 1394 | Line 1290 | public class ThreadPoolExecutorSubclassT
1290      /**
1291       * invokeAll(c) returns results of all completed tasks
1292       */
1293 <    public void testInvokeAll5() {
1294 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1293 >    public void testInvokeAll5() throws Exception {
1294 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1295          try {
1296              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1297              l.add(new StringTask());
1298              l.add(new StringTask());
1299              List<Future<String>> result = e.invokeAll(l);
1300              assertEquals(2, result.size());
1301 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1302 <                assertSame(TEST_STRING, it.next().get());
1407 <        } catch (ExecutionException success) {
1408 <        } catch(Exception ex) {
1409 <            unexpectedException();
1301 >            for (Future<String> future : result)
1302 >                assertSame(TEST_STRING, future.get());
1303          } finally {
1304              joinPool(e);
1305          }
# Line 1417 | Line 1310 | public class ThreadPoolExecutorSubclassT
1310      /**
1311       * timed invokeAny(null) throws NPE
1312       */
1313 <    public void testTimedInvokeAny1() {
1314 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1313 >    public void testTimedInvokeAny1() throws Exception {
1314 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1315          try {
1316 <            e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1316 >            e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1317 >            shouldThrow();
1318          } catch (NullPointerException success) {
1425        } catch(Exception ex) {
1426            unexpectedException();
1319          } finally {
1320              joinPool(e);
1321          }
# Line 1432 | Line 1324 | public class ThreadPoolExecutorSubclassT
1324      /**
1325       * timed invokeAny(,,null) throws NPE
1326       */
1327 <    public void testTimedInvokeAnyNullTimeUnit() {
1328 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1327 >    public void testTimedInvokeAnyNullTimeUnit() throws Exception {
1328 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1329          try {
1330              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1331              l.add(new StringTask());
1332              e.invokeAny(l, MEDIUM_DELAY_MS, null);
1333 +            shouldThrow();
1334          } catch (NullPointerException success) {
1442        } catch(Exception ex) {
1443            unexpectedException();
1335          } finally {
1336              joinPool(e);
1337          }
# Line 1449 | Line 1340 | public class ThreadPoolExecutorSubclassT
1340      /**
1341       * timed invokeAny(empty collection) throws IAE
1342       */
1343 <    public void testTimedInvokeAny2() {
1344 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1343 >    public void testTimedInvokeAny2() throws Exception {
1344 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1345          try {
1346 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1346 >            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1347 >            shouldThrow();
1348          } catch (IllegalArgumentException success) {
1457        } catch(Exception ex) {
1458            unexpectedException();
1349          } finally {
1350              joinPool(e);
1351          }
# Line 1464 | Line 1354 | public class ThreadPoolExecutorSubclassT
1354      /**
1355       * timed invokeAny(c) throws NPE if c has null elements
1356       */
1357 <    public void testTimedInvokeAny3() {
1358 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1357 >    public void testTimedInvokeAny3() throws Exception {
1358 >        final CountDownLatch latch = new CountDownLatch(1);
1359 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1360          try {
1361              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1362 <            l.add(new StringTask());
1362 >            l.add(new Callable<String>() {
1363 >                      public String call() {
1364 >                          try {
1365 >                              latch.await();
1366 >                          } catch (InterruptedException ok) {}
1367 >                          return TEST_STRING;
1368 >                      }});
1369              l.add(null);
1370 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1370 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1371 >            shouldThrow();
1372          } catch (NullPointerException success) {
1475        } catch(Exception ex) {
1476            ex.printStackTrace();
1477            unexpectedException();
1373          } finally {
1374 +            latch.countDown();
1375              joinPool(e);
1376          }
1377      }
# Line 1483 | Line 1379 | public class ThreadPoolExecutorSubclassT
1379      /**
1380       * timed invokeAny(c) throws ExecutionException if no task completes
1381       */
1382 <    public void testTimedInvokeAny4() {
1383 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1382 >    public void testTimedInvokeAny4() throws Exception {
1383 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1384          try {
1385              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1386              l.add(new NPETask());
1387 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1388 <        } catch(ExecutionException success) {
1389 <        } catch(Exception ex) {
1390 <            unexpectedException();
1387 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1388 >            shouldThrow();
1389 >        } catch (ExecutionException success) {
1390 >            assertTrue(success.getCause() instanceof NullPointerException);
1391          } finally {
1392              joinPool(e);
1393          }
# Line 1500 | Line 1396 | public class ThreadPoolExecutorSubclassT
1396      /**
1397       * timed invokeAny(c) returns result of some task
1398       */
1399 <    public void testTimedInvokeAny5() {
1400 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1399 >    public void testTimedInvokeAny5() throws Exception {
1400 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1401          try {
1402              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1403              l.add(new StringTask());
1404              l.add(new StringTask());
1405 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1405 >            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1406              assertSame(TEST_STRING, result);
1511        } catch (ExecutionException success) {
1512        } catch(Exception ex) {
1513            unexpectedException();
1407          } finally {
1408              joinPool(e);
1409          }
# Line 1519 | Line 1412 | public class ThreadPoolExecutorSubclassT
1412      /**
1413       * timed invokeAll(null) throws NPE
1414       */
1415 <    public void testTimedInvokeAll1() {
1416 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1415 >    public void testTimedInvokeAll1() throws Exception {
1416 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1417          try {
1418 <            e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1418 >            e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1419 >            shouldThrow();
1420          } catch (NullPointerException success) {
1527        } catch(Exception ex) {
1528            unexpectedException();
1421          } finally {
1422              joinPool(e);
1423          }
# Line 1534 | Line 1426 | public class ThreadPoolExecutorSubclassT
1426      /**
1427       * timed invokeAll(,,null) throws NPE
1428       */
1429 <    public void testTimedInvokeAllNullTimeUnit() {
1430 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1429 >    public void testTimedInvokeAllNullTimeUnit() throws Exception {
1430 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1431          try {
1432              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1433              l.add(new StringTask());
1434              e.invokeAll(l, MEDIUM_DELAY_MS, null);
1435 +            shouldThrow();
1436          } catch (NullPointerException success) {
1544        } catch(Exception ex) {
1545            unexpectedException();
1437          } finally {
1438              joinPool(e);
1439          }
# Line 1551 | Line 1442 | public class ThreadPoolExecutorSubclassT
1442      /**
1443       * timed invokeAll(empty collection) returns empty collection
1444       */
1445 <    public void testTimedInvokeAll2() {
1446 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1445 >    public void testTimedInvokeAll2() throws Exception {
1446 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1447          try {
1448 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1448 >            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1449              assertTrue(r.isEmpty());
1559        } catch(Exception ex) {
1560            unexpectedException();
1450          } finally {
1451              joinPool(e);
1452          }
# Line 1566 | Line 1455 | public class ThreadPoolExecutorSubclassT
1455      /**
1456       * timed invokeAll(c) throws NPE if c has null elements
1457       */
1458 <    public void testTimedInvokeAll3() {
1459 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1458 >    public void testTimedInvokeAll3() throws Exception {
1459 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1460          try {
1461              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1462              l.add(new StringTask());
1463              l.add(null);
1464 <            e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1464 >            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1465 >            shouldThrow();
1466          } catch (NullPointerException success) {
1577        } catch(Exception ex) {
1578            unexpectedException();
1467          } finally {
1468              joinPool(e);
1469          }
# Line 1584 | Line 1472 | public class ThreadPoolExecutorSubclassT
1472      /**
1473       * get of element of invokeAll(c) throws exception on failed task
1474       */
1475 <    public void testTimedInvokeAll4() {
1476 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1475 >    public void testTimedInvokeAll4() throws Exception {
1476 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1477          try {
1478              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1479              l.add(new NPETask());
1480 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1480 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1481              assertEquals(1, result.size());
1482 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1483 <                it.next().get();
1484 <        } catch(ExecutionException success) {
1485 <        } catch(Exception ex) {
1486 <            unexpectedException();
1482 >            for (Future<String> future : result)
1483 >                future.get();
1484 >            shouldThrow();
1485 >        } catch (ExecutionException success) {
1486 >            assertTrue(success.getCause() instanceof NullPointerException);
1487          } finally {
1488              joinPool(e);
1489          }
# Line 1604 | Line 1492 | public class ThreadPoolExecutorSubclassT
1492      /**
1493       * timed invokeAll(c) returns results of all completed tasks
1494       */
1495 <    public void testTimedInvokeAll5() {
1496 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1495 >    public void testTimedInvokeAll5() throws Exception {
1496 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1497          try {
1498              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1499              l.add(new StringTask());
1500              l.add(new StringTask());
1501 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1501 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1502              assertEquals(2, result.size());
1503 <            for (Iterator<Future<String>> it = result.iterator(); it.hasNext();)
1504 <                assertSame(TEST_STRING, it.next().get());
1617 <        } catch (ExecutionException success) {
1618 <        } catch(Exception ex) {
1619 <            unexpectedException();
1503 >            for (Future<String> future : result)
1504 >                assertSame(TEST_STRING, future.get());
1505          } finally {
1506              joinPool(e);
1507          }
# Line 1625 | Line 1510 | public class ThreadPoolExecutorSubclassT
1510      /**
1511       * timed invokeAll(c) cancels tasks not completed by timeout
1512       */
1513 <    public void testTimedInvokeAll6() {
1514 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1513 >    public void testTimedInvokeAll6() throws Exception {
1514 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1515          try {
1516              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1517              l.add(new StringTask());
1518              l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
1519              l.add(new StringTask());
1520 <            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
1520 >            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);
1521              assertEquals(3, result.size());
1522 <            Iterator<Future<String>> it = result.iterator();
1522 >            Iterator<Future<String>> it = result.iterator();
1523              Future<String> f1 = it.next();
1524              Future<String> f2 = it.next();
1525              Future<String> f3 = it.next();
# Line 1643 | Line 1528 | public class ThreadPoolExecutorSubclassT
1528              assertTrue(f3.isDone());
1529              assertFalse(f1.isCancelled());
1530              assertTrue(f2.isCancelled());
1646        } catch(Exception ex) {
1647            unexpectedException();
1531          } finally {
1532              joinPool(e);
1533          }
# Line 1654 | Line 1537 | public class ThreadPoolExecutorSubclassT
1537       * Execution continues if there is at least one thread even if
1538       * thread factory fails to create more
1539       */
1540 <    public void testFailingThreadFactory() {
1541 <        ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new FailingThreadFactory());
1540 >    public void testFailingThreadFactory() throws InterruptedException {
1541 >        ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new FailingThreadFactory());
1542          try {
1660            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1543              for (int k = 0; k < 100; ++k) {
1544                  e.execute(new NoOpRunnable());
1545              }
1546              Thread.sleep(LONG_DELAY_MS);
1665        } catch(Exception ex) {
1666            unexpectedException();
1547          } finally {
1548              joinPool(e);
1549          }
# Line 1673 | Line 1553 | public class ThreadPoolExecutorSubclassT
1553       * allowsCoreThreadTimeOut is by default false.
1554       */
1555      public void testAllowsCoreThreadTimeOut() {
1556 <        ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1556 >        ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1557          assertFalse(tpe.allowsCoreThreadTimeOut());
1558          joinPool(tpe);
1559      }
# Line 1681 | Line 1561 | public class ThreadPoolExecutorSubclassT
1561      /**
1562       * allowCoreThreadTimeOut(true) causes idle threads to time out
1563       */
1564 <    public void testAllowCoreThreadTimeOut_true() {
1565 <        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1564 >    public void testAllowCoreThreadTimeOut_true() throws InterruptedException {
1565 >        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1566          tpe.allowCoreThreadTimeOut(true);
1567          tpe.execute(new NoOpRunnable());
1568          try {
1569              Thread.sleep(MEDIUM_DELAY_MS);
1570              assertEquals(0, tpe.getPoolSize());
1691        } catch(InterruptedException e){
1692            unexpectedException();
1571          } finally {
1572              joinPool(tpe);
1573          }
# Line 1698 | Line 1576 | public class ThreadPoolExecutorSubclassT
1576      /**
1577       * allowCoreThreadTimeOut(false) causes idle threads not to time out
1578       */
1579 <    public void testAllowCoreThreadTimeOut_false() {
1580 <        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1579 >    public void testAllowCoreThreadTimeOut_false() throws InterruptedException {
1580 >        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1581          tpe.allowCoreThreadTimeOut(false);
1582          tpe.execute(new NoOpRunnable());
1583          try {
1584              Thread.sleep(MEDIUM_DELAY_MS);
1585              assertTrue(tpe.getPoolSize() >= 1);
1708        } catch(InterruptedException e){
1709            unexpectedException();
1586          } finally {
1587              joinPool(tpe);
1588          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines