public boolean cancel(boolean mayInterruptIfRunning) { synchronized (this) { if (ranOrCancelled()) return false; state = CANCELLED; if (mayInterruptIfRunning) { Thread r = runner; if (r != null) r.interrupt(); } runner = null; notifyAll(); } done(); return true; }
public boolean cancel(boolean mayInterruptIfRunning) { synchronized (this) { if (ranOrCancelled()) return false; state = CANCELLED; if (mayInterruptIfRunning) { Thread r = runner; if (r != null) r.interrupt(); } runner = null; notifyAll(); } done(); return true; }
public boolean cancel(boolean mayInterruptIfRunning) { synchronized (this) { if (ranOrCancelled()) return false; state = CANCELLED; if (mayInterruptIfRunning) { Thread r = runner; if (r != null) r.interrupt(); } runner = null; notifyAll(); } done(); return true; }
/** * Marks the task as failed. * @param exception the cause of abrupt completion. */ private void setFailed(Throwable exception) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.exception = exception; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }
/** * Marks the task as completed. * @param result the result of a task. */ private void setCompleted(Object result) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.result = result; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }
/** * Marks the task as failed. * @param exception the cause of abrupt completion. */ private void setFailed(Throwable exception) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.exception = exception; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }
/** * Marks the task as failed. * @param exception the cause of abrupt completion. */ private void setFailed(Throwable exception) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.exception = exception; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }
/** * Marks the task as completed. * @param result the result of a task. */ private void setCompleted(Object result) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.result = result; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }
/** * Marks the task as completed. * @param result the result of a task. */ private void setCompleted(Object result) { synchronized (this) { if (ranOrCancelled()) return; this.state = RAN; this.result = result; this.runner = null; notifyAll(); } // invoking callbacks *after* setting future as completed and // outside the synchronization block makes it safe to call // interrupt() from within callback code (in which case it will be // ignored rather than cause deadlock / illegal state exception) done(); }