Parimala Ramdas wrote:it appears that calling Future.cancel(true) doesn't cancel the thread
This call does cancel
the submitted task, not the thread.
In your program only task number 4 is cancelled ...take a thorough look at the output, the task no. 4 doesn't appear in the output
- it is canceled so it even does not start:
Parimala Ramdas wrote: and calling shutdown() doesn't really close down the pool.
Shutdown doesn't stop/cancel submitted tasks - after shutdown() is called, no new tasks can be submitted to the pool,
but the pool continues executing already submitted tasks.
If you want to stop tasks that are submitted/executed by the pool, you must call shutdownNow.
Consult api docs for details:
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html