public void cancel() { if (thread == null) return; if (!thread.isAlive()) { thread.interrupt(); return; } task.cancel(); }