title: How to get thread id from a thread pool?
body: <p>I have a fixed thread pool that I submit tasks to (limited to <strong>5</strong> threads). How can I find out which one of those <strong>5</strong> threads executes my task (something like "thread #3 of <strong>5</strong> is doing this task")?</p>
  
  <pre><code>ExecutorService taskExecutor = Executors.newFixedThreadPool(5);
  
  //in infinite loop:
  taskExecutor.execute(new MyTask());
  ....
  
  private class MyTask implements Runnable {
      public void run() {
          logger.debug("Thread # XXX is doing this task");//how to get thread id?
      }
  }
  </code></pre>