/** * If the thread is currently active, calls {@link #executionCancelled()} to notify children. If * not active, removes the thread from the queue so it won't become active. */ public final void cancel() { boolean dependentThreads = false; synchronized (LOCK) { dependentThreads = checkQueuedThreadDependOnCurrentThread(); } if (dependentThreads) { if (ConfirmDialog.OK_OPTION != SwingTools.showConfirmDialog( "cancel_pg_with_dependencies", ConfirmDialog.OK_CANCEL_OPTION)) { return; } else { synchronized (LOCK) { removeQueuedThreadsWithDependency(getID()); } } } synchronized (LOCK) { cancelled = true; if (started) { executionCancelled(); currentThreads.remove(this); } else { // cancel and not started? Can only be in queue queuedThreads.remove(this); } } taskCancelled(this); }