title: How to init ThreadLocal variable in ThreadFactory?
body: <p>I have n resources and n threads, each thread will use a resource for its tasks.<br>
  When thread is created I want it to receive a resources and store it local thread variable.<br>
  When thread is done, I need to release the resource</p>
  
  <pre><code>ExecutorService pool = Executors.newFixedThreadPool(10, new ThreadFactory() {
          public Thread newThread(final Runnable r) {
              Thread thread = new Thread(new Runnable() {
                  public void run() {
                           //set ThreadLocal with a resource
                           //run   
                           //close the resource 
                  }
              });
                  return thread;
          }
  });
  </code></pre>