ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ThreadPoolExecutor.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ThreadPoolExecutor.java (file contents):
Revision 1.122 by jsr166, Mon May 19 01:09:45 2008 UTC vs.
Revision 1.123 by dl, Sun Oct 10 14:26:47 2010 UTC

# Line 1812 | Line 1812 | public class ThreadPoolExecutor extends
1812          }
1813      }
1814  
1815 +    /**
1816 +     * Returns a string identifying this pool, as well as its state,
1817 +     * including indications of run state and estimated worker and
1818 +     * task counts.
1819 +     *
1820 +     * @return a string identifying this pool, as well as its state
1821 +     */
1822 +    public String toString() {
1823 +        long ncompleted;
1824 +        int nworkers, nactive;
1825 +        final ReentrantLock mainLock = this.mainLock;
1826 +        mainLock.lock();
1827 +        try {
1828 +            ncompleted = completedTaskCount;
1829 +            nactive = 0;
1830 +            nworkers = workers.size();
1831 +            for (Worker w : workers) {
1832 +                ncompleted += w.completedTasks;
1833 +                if (w.isLocked())
1834 +                    ++nactive;
1835 +            }
1836 +        } finally {
1837 +            mainLock.unlock();
1838 +        }
1839 +        int c = ctl.get();
1840 +        String rs = (runStateLessThan(c, SHUTDOWN) ? "Running" :
1841 +                     (runStateAtLeast(c, TERMINATED) ? "Terminated" :
1842 +                      "Shutting down"));
1843 +        return super.toString() +
1844 +            "[" + rs +
1845 +            ", pool size = " + nworkers +
1846 +            ", active threads = " + nactive +
1847 +            ", queued tasks = " + workQueue.size() +
1848 +            ", completed tasks = " + ncompleted +
1849 +            "]";
1850 +    }
1851 +
1852      /* Extension hooks */
1853  
1854      /**
# Line 1932 | Line 1969 | public class ThreadPoolExecutor extends
1969           * @throws RejectedExecutionException always.
1970           */
1971          public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
1972 <            throw new RejectedExecutionException();
1972 >            throw new RejectedExecutionException("Task " + r.toString() +
1973 >                                                 " rejected from " +
1974 >                                                 e.toString());
1975          }
1976      }
1977  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines