Java tutorial
//package com.java2s; public class Main { public static void cancelAllTask(Thread... task) { for (Thread t : task) { if (t != null && (t.getState() == Thread.State.RUNNABLE || t.getState() != Thread.State.TERMINATED)) { t.interrupt(); t = null; } } } }