Code example for FutureTask

Methods: cancel

0
    if (future == null) {
      throw new UnsupportedOperationException(
          "You cannot cancel this task before calling future()"); 
    } 
 
    return future.cancel(mayInterruptIfRunning);
  } 
 
  /** @throws Exception, captured on passed to onException() if present. */ 
  protected void onPreExecute() throws Exception { 
  } 
 
  /** 
   * @param t the result of {@link #call()} 
   * @throws Exception, captured on passed to onException() if present. 
   */ 
  @SuppressWarnings({ "UnusedDeclaration" }) 
  protected void onSuccess(ResultT t) throws Exception {
  } 
 
  /**