title: My ThreadLocal contains and returns null always
body: <p>I am wondering how the threadlocal.set() has no data stored when I set it to a collection of 32 elements. ThreadLocal.get() returns null always; and the correspoding FutureTask object has an outcome property = NullPointerException. Any idea why ThreadLocal is unable to store collection items?</p>
  
  <pre><code>public class MyCallable&lt;T&gt; implements Callable&lt;Collection&lt;T&gt;&gt; {
  
      public MyCallable( Collection&lt;T&gt; items ){
          tLocal = new ThreadLocal&lt;Collection&lt;T&gt;&gt;();
          tLocal.set( items );                    //SETS NULL ALTHOUGH the PARAMETER CONTAINS 32 ITEMS
      }
  
      @Override
      @SuppressWarnings("unchecked")
      public Collection&lt;T&gt; call() throws Exception {
          synchronized( lock ){
              ArrayList&lt;T&gt; _items = new ArrayList&lt;T&gt;();
              ArrayList&lt;T&gt; _e = ( ArrayList&lt;T&gt; ) tLocal.get();   //RETURNS NULL
              for( T item : _e ){
                  _items = getPValue( item ));
              }
              return _items ;
          }
      }
  
      private ThreadLocal&lt;Collection&lt;T&gt;&gt; tLocal;
  
      private final Object lock = new Object();
  }
  </code></pre>
  
  <p>usage snippet:</p>
  
  <pre><code>List&lt;Future&lt;Collection&lt;T&gt;&gt;&gt; futures = new ArrayList&lt;Future&lt;Collection&lt;T&gt;&gt;&gt;();
  ExecutorService pool = Executors.newFixedThreadPool( 8 );
  
          for( int x = 0; x &lt; numBatches; ++x ){
              List&lt;T&gt; items = retrieveNext32Items( x );
              futures.add( pool.submit( new MyCallable&lt;T&gt;( items ));
          }
  
          pool.shutdown();
  
          for( Future&lt;Collection&lt;T&gt;&gt; future : futures ) {
              _items.addAll( future.get() );                  //future.outcome = NullPointerException 
          }
  
          return _items
  }
  </code></pre>