Code example for FutureTask

Methods: cancel

0
     * @see #isCancelled() 
     * @see #onCancelled(Object) 
     */ 
    public final boolean cancel(boolean mayInterruptIfRunning) {
        mCancelled.set(true);
        return mFuture.cancel(mayInterruptIfRunning);
    } 
 
    /** 
     * Waits if necessary for the computation to complete, and then 
     * retrieves its result. 
     * 
     * @return The computed result. 
     * 
     * @throws CancellationException If the computation was cancelled. 
     * @throws ExecutionException If the computation threw an exception. 
     * @throws InterruptedException If the current thread was interrupted 
     *         while waiting. 
     */ 
    public final Result get() throws InterruptedException, ExecutionException { 
        return mFuture.get();