Shift+Ctrl+Alt+u 生成
Future是一个接口
boolean cancel(boolean mayInterruptIfRunning);
boolean isCancelled();
boolean isDone();
get() throws InterruptedException, ExecutionException;
get(long timeout, TimeUnit unit);
throws InterruptedException, ExecutionException, TimeoutException;
RunnableFuture 接口 继承了Runnable, Future 接口
FutureTask 实现了RunnableFuture接口
public FutureTask(Callable<V> callable) {
if (callable == null)
throw new NullPointerException();
this.callable = callable;
this.state = NEW; // ensure visibility of callable
}
public boolean cancel(boolean mayInterruptIfRunning) {
if (!(state == NEW &&
UNSAFE.compareAndSwapInt(this, stateOffset, NEW,
mayInterruptIfRunning ? INTERRUPTING : CANCELLED)))
return false;
try {
// in case call to interrupt throws exception
if (mayInterruptIfRunning) {
try {
Thread t = runner;
if (t != null)
t.interrupt()