title: How to get number of current running and queued threads from ThreadPoolExecutor?
body: <p>I need to get number of running threads in a ThreadPoolExecutor, as well as the Queue size.</p>
  
  <p>I have a working implementation as (keep track of each futures in an arraylist and count which is not completed):</p>
  
  <pre><code>java.util.concurrent.ArrayBlockingQueue&lt;Runnable&gt; threadpoolQueue = 
      new java.util.concurrent.ArrayBlockingQueue&lt;Runnable&gt;(10);
  
  ThreadPoolExecutor threadpool = new java.util.concurrent.ThreadPoolExecutor(0, 
      executingThreads, retryInterval, java.util.concurrent.TimeUnit.MILLISECONDS, threadpoolQueue);
  
  ArrayList&lt;Future&gt; threads = new ArrayList&lt;Future&gt;();
  
  threads.add(threadpool.submit(/*Runnable*/));
  
  //Get Sizes
  int threadpoolRunningThreads = 0;
  for (Future obj : threads) {
      if (!obj.isDone()) {
           threadpoolRunningThreads++;
      }
  }
  logger.debug("Merging all threads threadpool.size=" + threadpoolRunningThreads 
      + ",threadpool.queue.size="+ threadpoolQueue.size());
  </code></pre>
  
  <p>This is a very awkward way of tracking threadpool, and I don't see any methods provided in threadpool that allows to get the number for running and queued threads. I wanna do something like:</p>
  
  <pre><code>threadpool.getIncompletedTaskSize();
  threadpool.getQueuedTaskSize();
  </code></pre>
  
  <p>Can I achieve this? or at least something easier than my implementation? I am using <strong>Java 1.6</strong>.</p>