title: Future task of ExecutorService not truly cancelling
body: <p>I push my Futures from a ExecutorService into a hash map.  Later, I may call cancel on Futures from within the hash map.  Although the result is true, I later hit breakpoints within the Callable procedure, as if the Future cancel() had no effect.  I think it might be a case of two different references here (even though the reference IDs are listed as the same when breakpointing), but was wondering if some experts could chime in.  Here's what the code looks like:</p>
  
  <pre><code>ExecutorService taskExecutor = Executors.newCachedThreadPool();
  Map &lt;String, Future&lt;Object&gt;&gt; results = new HashMap &lt;String, Future&lt;Object&gt;&gt;();      
  
  Future&lt;Object&gt; future = taskExecutor.submit(new MyProcessor(uid));
  results.put(uid, future);
  </code></pre>
  
  <p>I allow processing to continue (it's a loop that submits tasks as they are passed in), and later I may attempt to cancel from an outside source by calling this method:</p>
  
  <pre><code>public static synchronized boolean cancelThread(String uid) {
      Future&lt;Object&gt; future = results.get(uid);
      boolean success = false;
      if (future != null) {
          success = (future.isDone() ? true : future.cancel(true));
          if (success)
              results.remove(uid);
      }
      return success;     
  }
  </code></pre>
  
  <p>But I still encounter a "non-cancelled" path within MyProcessor.call() after future.cancel() is called - i.e. it's not really being cancelled.</p>
  
  <p>Where am I going wrong with this?  Is there a better was to do this?</p>