Executor 任务执行器
Executor: 是一个接口 用于执行提交的任务 解耦任务提交和执行(线程的创建及调度) Executor的实现可以根据实际需求延展不同的逻辑:1. 对于提交的任务同步或者异步执行,如下同步执行: class ThreadPerTaskExecutor implements Executor { public void execute(Runnable r) { new Thread(r).start(); } 2. 另起线程执行任务,如下: class ThreadPerTaskExecutor implements Executor { public void execute(Runnable r) { new Thread(r).start(); } 3. 对于执行的任务添加限制: class SerialExecutor implements Executor { final Queue<Runnable> tasks = new ArrayDeque<Runnable>(); final Executor executor; Runnable active; SerialExecutor(Executor executor) { this.executor = executor; } public synchronized void execute(final