publicclassAsyncResult<T>implementsFuture<T>{privateT result;publicAsyncResult(T result){this.result = result;}/**
* 异步任务不支持取消操作,直接返回false
* @param mayInterruptIfRunning {@code true} if the thread executing this
* task should be interrupted; otherwise, in-progress tasks are allowed
* to complete
* @return
*/@Overridepublicbooleancancel(boolean mayInterruptIfRunning){returnfalse;}/**
* 异步任务不支持取消操作,直接返回false
* @return
*/@OverridepublicbooleanisCancelled(){returnfalse;}@OverridepublicbooleanisDone(){returnfalse;}/**
* 直接返回异步执行的结果
* @return
*/@OverridepublicTget()throwsInterruptedException,ExecutionException{return result;}/**
* 直接返回异步执行的结果,不等待超时时间
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws TimeoutException
*/@OverridepublicTget(long timeout,TimeUnit unit)throwsInterruptedException,ExecutionException,TimeoutException{return result;}}