Code example for FutureTask

0
		this.executor = executor;
	} 
 
 
	public FutureTask<Void> future() {
		future = new FutureTask<Void>(newTask());
		return future;
	} 
 
	public SafeAsyncTask<ResultT> executor(Executor executor) {
		this.executor = executor;
		return this;
	} 
 
	public Executor executor() {
		return executor;
	} 
 
	public SafeAsyncTask<ResultT> handler(Handler handler) {
		this.handler = handler;
		return this;
	} 
 
	public Handler handler() {
		return handler;
	} 
 
	public void execute() { 
		execute(Thread.currentThread().getStackTrace());
	} 
 
	protected void execute(StackTraceElement[] launchLocation) {
		this.launchLocation = launchLocation;
		executor.execute(future());
	} 
 
	public boolean cancel(boolean mayInterruptIfRunning) {
		if (future == null) throw new UnsupportedOperationException("You cannot cancel this task before calling future()");