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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.110 by jsr166, Tue Oct 6 16:39:06 2015 UTC vs.
Revision 1.114 by jsr166, Wed Jan 4 06:09:58 2017 UTC

# Line 28 | Line 28 | import java.util.concurrent.RejectedExec
28   import java.util.concurrent.SynchronousQueue;
29   import java.util.concurrent.ThreadFactory;
30   import java.util.concurrent.ThreadPoolExecutor;
31 import java.util.concurrent.TimeUnit;
31   import java.util.concurrent.atomic.AtomicInteger;
32  
33   import junit.framework.Test;
# Line 537 | Line 536 | public class ThreadPoolExecutorTest exte
536       */
537      public void testGetQueue() throws InterruptedException {
538          final CountDownLatch done = new CountDownLatch(1);
539 <        final BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
539 >        final BlockingQueue<Runnable> q = new ArrayBlockingQueue<>(10);
540          final ThreadPoolExecutor p =
541              new ThreadPoolExecutor(1, 1,
542                                     LONG_DELAY_MS, MILLISECONDS,
# Line 569 | Line 568 | public class ThreadPoolExecutorTest exte
568       */
569      public void testRemove() throws InterruptedException {
570          final CountDownLatch done = new CountDownLatch(1);
571 <        BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
571 >        BlockingQueue<Runnable> q = new ArrayBlockingQueue<>(10);
572          final ThreadPoolExecutor p =
573              new ThreadPoolExecutor(1, 1,
574                                     LONG_DELAY_MS, MILLISECONDS,
# Line 604 | Line 603 | public class ThreadPoolExecutorTest exte
603      public void testPurge() throws InterruptedException {
604          final CountDownLatch threadStarted = new CountDownLatch(1);
605          final CountDownLatch done = new CountDownLatch(1);
606 <        final BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
606 >        final BlockingQueue<Runnable> q = new ArrayBlockingQueue<>(10);
607          final ThreadPoolExecutor p =
608              new ThreadPoolExecutor(1, 1,
609                                     LONG_DELAY_MS, MILLISECONDS,
# Line 1508 | Line 1507 | public class ThreadPoolExecutorTest exte
1507                                     LONG_DELAY_MS, MILLISECONDS,
1508                                     new ArrayBlockingQueue<Runnable>(10));
1509          try (PoolCleaner cleaner = cleaner(e)) {
1510 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1510 >            List<Callable<String>> l = new ArrayList<>();
1511              l.add(latchAwaitingStringTask(latch));
1512              l.add(null);
1513              try {
# Line 1528 | Line 1527 | public class ThreadPoolExecutorTest exte
1527                                     LONG_DELAY_MS, MILLISECONDS,
1528                                     new ArrayBlockingQueue<Runnable>(10));
1529          try (PoolCleaner cleaner = cleaner(e)) {
1530 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1530 >            List<Callable<String>> l = new ArrayList<>();
1531              l.add(new NPETask());
1532              try {
1533                  e.invokeAny(l);
# Line 1548 | Line 1547 | public class ThreadPoolExecutorTest exte
1547                                     LONG_DELAY_MS, MILLISECONDS,
1548                                     new ArrayBlockingQueue<Runnable>(10));
1549          try (PoolCleaner cleaner = cleaner(e)) {
1550 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1550 >            List<Callable<String>> l = new ArrayList<>();
1551              l.add(new StringTask());
1552              l.add(new StringTask());
1553              String result = e.invokeAny(l);
# Line 1595 | Line 1594 | public class ThreadPoolExecutorTest exte
1594                                     LONG_DELAY_MS, MILLISECONDS,
1595                                     new ArrayBlockingQueue<Runnable>(10));
1596          try (PoolCleaner cleaner = cleaner(e)) {
1597 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1597 >            List<Callable<String>> l = new ArrayList<>();
1598              l.add(new StringTask());
1599              l.add(null);
1600              try {
# Line 1614 | Line 1613 | public class ThreadPoolExecutorTest exte
1613                                     LONG_DELAY_MS, MILLISECONDS,
1614                                     new ArrayBlockingQueue<Runnable>(10));
1615          try (PoolCleaner cleaner = cleaner(e)) {
1616 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1616 >            List<Callable<String>> l = new ArrayList<>();
1617              l.add(new NPETask());
1618              List<Future<String>> futures = e.invokeAll(l);
1619              assertEquals(1, futures.size());
# Line 1636 | Line 1635 | public class ThreadPoolExecutorTest exte
1635                                     LONG_DELAY_MS, MILLISECONDS,
1636                                     new ArrayBlockingQueue<Runnable>(10));
1637          try (PoolCleaner cleaner = cleaner(e)) {
1638 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1638 >            List<Callable<String>> l = new ArrayList<>();
1639              l.add(new StringTask());
1640              l.add(new StringTask());
1641              List<Future<String>> futures = e.invokeAll(l);
# Line 1671 | Line 1670 | public class ThreadPoolExecutorTest exte
1670                                     LONG_DELAY_MS, MILLISECONDS,
1671                                     new ArrayBlockingQueue<Runnable>(10));
1672          try (PoolCleaner cleaner = cleaner(e)) {
1673 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1673 >            List<Callable<String>> l = new ArrayList<>();
1674              l.add(new StringTask());
1675              try {
1676                  e.invokeAny(l, MEDIUM_DELAY_MS, null);
# Line 1707 | Line 1706 | public class ThreadPoolExecutorTest exte
1706                                     LONG_DELAY_MS, MILLISECONDS,
1707                                     new ArrayBlockingQueue<Runnable>(10));
1708          try (PoolCleaner cleaner = cleaner(e)) {
1709 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1709 >            List<Callable<String>> l = new ArrayList<>();
1710              l.add(latchAwaitingStringTask(latch));
1711              l.add(null);
1712              try {
# Line 1727 | Line 1726 | public class ThreadPoolExecutorTest exte
1726                                     LONG_DELAY_MS, MILLISECONDS,
1727                                     new ArrayBlockingQueue<Runnable>(10));
1728          try (PoolCleaner cleaner = cleaner(e)) {
1729 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1729 >            long startTime = System.nanoTime();
1730 >            List<Callable<String>> l = new ArrayList<>();
1731              l.add(new NPETask());
1732              try {
1733 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1733 >                e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1734                  shouldThrow();
1735              } catch (ExecutionException success) {
1736                  assertTrue(success.getCause() instanceof NullPointerException);
1737              }
1738 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1739          }
1740      }
1741  
# Line 1747 | Line 1748 | public class ThreadPoolExecutorTest exte
1748                                     LONG_DELAY_MS, MILLISECONDS,
1749                                     new ArrayBlockingQueue<Runnable>(10));
1750          try (PoolCleaner cleaner = cleaner(e)) {
1751 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1751 >            long startTime = System.nanoTime();
1752 >            List<Callable<String>> l = new ArrayList<>();
1753              l.add(new StringTask());
1754              l.add(new StringTask());
1755 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1755 >            String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS);
1756              assertSame(TEST_STRING, result);
1757 +            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
1758          }
1759      }
1760  
# Line 1780 | Line 1783 | public class ThreadPoolExecutorTest exte
1783                                     LONG_DELAY_MS, MILLISECONDS,
1784                                     new ArrayBlockingQueue<Runnable>(10));
1785          try (PoolCleaner cleaner = cleaner(e)) {
1786 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1786 >            List<Callable<String>> l = new ArrayList<>();
1787              l.add(new StringTask());
1788              try {
1789                  e.invokeAll(l, MEDIUM_DELAY_MS, null);
# Line 1813 | Line 1816 | public class ThreadPoolExecutorTest exte
1816                                     LONG_DELAY_MS, MILLISECONDS,
1817                                     new ArrayBlockingQueue<Runnable>(10));
1818          try (PoolCleaner cleaner = cleaner(e)) {
1819 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1819 >            List<Callable<String>> l = new ArrayList<>();
1820              l.add(new StringTask());
1821              l.add(null);
1822              try {
# Line 1832 | Line 1835 | public class ThreadPoolExecutorTest exte
1835                                     LONG_DELAY_MS, MILLISECONDS,
1836                                     new ArrayBlockingQueue<Runnable>(10));
1837          try (PoolCleaner cleaner = cleaner(e)) {
1838 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1838 >            List<Callable<String>> l = new ArrayList<>();
1839              l.add(new NPETask());
1840              List<Future<String>> futures =
1841                  e.invokeAll(l, LONG_DELAY_MS, MILLISECONDS);
# Line 1855 | Line 1858 | public class ThreadPoolExecutorTest exte
1858                                     LONG_DELAY_MS, MILLISECONDS,
1859                                     new ArrayBlockingQueue<Runnable>(10));
1860          try (PoolCleaner cleaner = cleaner(e)) {
1861 <            List<Callable<String>> l = new ArrayList<Callable<String>>();
1861 >            List<Callable<String>> l = new ArrayList<>();
1862              l.add(new StringTask());
1863              l.add(new StringTask());
1864              List<Future<String>> futures =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines