title: Number of active tasks using ThreadPoolExecutor
body: <p>I am using a ThreadPoolExecutor to execute tasks in my Java application. I have a requirement where I want to get the number of active tasks in the queue at any point in time in the executor queue . I looked up at the <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="noreferrer">javadoc</a> for ThreadPoolExecutor and found two relevant methods: <code>getTaskCount()</code> and <code>getCompletedTaskCount()</code>.</p>
  
  <p>Per the documentation, I could get the number of scheduled tasks and completed tasks from the above two methods respectively. But I am not able to find a solution for getting the number of active tasks in the queue at any point in time. I can do something like:</p>
  
  <pre><code>getTaskCount() = getCompletedTaskCount() + failed tasks + active tasks
  </code></pre>
  
  <p>But the number of failed tasks is not directly available to arrive at the intended calculation. </p>
  
  <p>Am I missing something here ?</p>