任务类
Runnable
public interface Runnable {
public abstract void run();
}Callable
public interface Callable<V> {
V call() throws Exception;
}Future
public interface Future<V> {
boolean cancel(boolean mayInterruptIfRunning);
boolean isCancelled();
boolean isDone();
//阻塞,直到任务完成
V get() throws InterruptedException, ExecutionException;
//阻塞一段时间,或任务完成
V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
}FutureTask
Last updated