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.21 by jsr166, Mon Oct 11 07:21:32 2010 UTC vs.
Revision 1.28 by jsr166, Sat May 7 19:49:37 2011 UTC

# Line 1 | Line 1
1   /*
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
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
# Line 60 | Line 60 | public class ThreadPoolExecutorSubclassT
60              finally { lock.unlock() ; }
61          }
62          public void run() {
63            boolean runme;
63              lock.lock();
64              try {
65 <                runme = !done;
66 <                if (!runme)
67 <                    thread = Thread.currentThread();
65 >                if (done)
66 >                    return;
67 >                thread = Thread.currentThread();
68              }
69              finally { lock.unlock() ; }
71            if (!runme) return;
70              V v = null;
71              Exception e = null;
72              try {
# Line 292 | Line 290 | public class ThreadPoolExecutorSubclassT
290              assertEquals(0, p.getCompletedTaskCount());
291              threadProceed.countDown();
292              threadDone.await();
293 <            Thread.sleep(SHORT_DELAY_MS);
293 >            delay(SHORT_DELAY_MS);
294              assertEquals(1, p.getCompletedTaskCount());
295          } finally {
296              joinPool(p);
# Line 486 | Line 484 | public class ThreadPoolExecutorSubclassT
484      }
485  
486      /**
487 <     * isShutDown is false before shutdown, true after
487 >     * isShutdown is false before shutdown, true after
488       */
489      public void testIsShutdown() {
490  
# Line 512 | Line 510 | public class ThreadPoolExecutorSubclassT
510              assertFalse(p.isTerminating());
511              p.execute(new CheckedRunnable() {
512                  public void realRun() throws InterruptedException {
515                    threadStarted.countDown();
513                      assertFalse(p.isTerminating());
514 +                    threadStarted.countDown();
515                      done.await();
516                  }});
517              assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
# Line 541 | Line 539 | public class ThreadPoolExecutorSubclassT
539              assertFalse(p.isTerminating());
540              p.execute(new CheckedRunnable() {
541                  public void realRun() throws InterruptedException {
544                    threadStarted.countDown();
542                      assertFalse(p.isTerminating());
543 +                    threadStarted.countDown();
544                      done.await();
545                  }});
546              assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
# Line 671 | Line 669 | public class ThreadPoolExecutorSubclassT
669      }
670  
671      /**
672 <     * shutDownNow returns a list containing tasks that were not run
672 >     * shutdownNow returns a list containing tasks that were not run
673       */
674 <    public void testShutDownNow() {
674 >    public void testShutdownNow() {
675          ThreadPoolExecutor p = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
676          List l;
677          try {
# Line 1253 | Line 1251 | public class ThreadPoolExecutorSubclassT
1251          try {
1252              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
1253              p.execute(r);
1254 <            Thread.sleep(SHORT_DELAY_MS);
1254 >            delay(SHORT_DELAY_MS);
1255              assertTrue(r.done);
1256              assertTrue(p.beforeCalled);
1257              assertTrue(p.afterCalled);
# Line 1744 | Line 1742 | public class ThreadPoolExecutorSubclassT
1742              for (int i = 0; i < (MEDIUM_DELAY_MS/10); i++) {
1743                  if (p.getPoolSize() == 0)
1744                      break;
1745 <                Thread.sleep(10);
1745 >                delay(10);
1746              }
1747              assertEquals(0, p.getPoolSize());
1748          } finally {
# Line 1768 | Line 1766 | public class ThreadPoolExecutorSubclassT
1766                      threadStarted.countDown();
1767                      assertTrue(p.getPoolSize() >= 1);
1768                  }});
1769 <            Thread.sleep(SMALL_DELAY_MS);
1769 >            delay(SMALL_DELAY_MS);
1770              assertTrue(p.getPoolSize() >= 1);
1771          } finally {
1772              joinPool(p);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines