Executor的系列类图如下:这一些了类或接口都是和任务提交和执行相关的。
- java.util.concurrent.AbstractExecutorService (implements java.util.concurrent.ExecutorService extends java.util.concurrent.Executor)
- java.util.concurrent.ThreadPoolExecutor
- java.util.concurrent.ScheduledThreadPoolExecutor (implements java.util.concurrent.ScheduledExecutorService extends java.util.concurrent.ExecutorService)
- java.util.concurrent.ThreadPoolExecutor
- java.util.concurrent.Executors
java.util.concurrent.Executor接口:
/* @since 1.5
* @author Doug Lea
*/
public interface Executor {
/**
* Executes the given command at some time in the future. The command
* may execute in a new thread, in a pooled thread, or in the calling
* thread, at the discretion of the <tt>Executor</tt> implementation.
*会在将来某个时刻去执行任务,也就是所谓的异步执行
*
* @param command the runnable task
* @throws RejectedExecutionException if this task cannot be
* accepted for execution.
* @throws NullPointerException if command is null
*/
void execute(Runnable command);
}
java.util.concurrent.ExecutorService接口,该接口定义的方法如下:

这些方法一部分在AbstractExecutorService提供了默认的实现,一部分延迟到ThreadPoolExecutor里实现。
java.util.concurrent.AbstractExecutorService抽象类:
java.util.concurrent.ThreadPoolExecutor类: