Executor是java并发包里面的一个接口,其里面只有一个方法:
void execute(Runnable command);
通常我们使用Executor时会使用ExecutorService接口,该接口集成了Executor接口同时还实定义了其它方法,具体可以从代码中看出:
public interface ExecutorService extends Executor {
void shutdown();
List<Runnable> shutdownNow();
boolean isShutdown();
boolean isTerminated();
boolean awaitTermination(long timeout, TimeUnit unit)throws InterruptedException;
<T> Future<T> submit(Callable<T> task);
<T> Future<T> submit(Runnable task, T result);
Future<?> submit(Runnable task);
<T> T invokeAny(Collection<? extends Callable<T>> tasks,long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
}