Use java.util.concurrent package instead of manually run a Thread object

Instantiate ExecutorService

ExecutorService executor = new ThreadPoolExecutor(3, 5, 5, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());

or

ExecutorService executor = Executors.newCachedThreadPool();    // general condition, unlimited threads

ExecutorService executor = Executors.newFixedThreadPool();       // heavily loaded server, limited threads

Run a task(thread)

Future future = executor.submit(new Thread {public void run() {....}});

Cancel a task

future.cancel(true);