ThreadPoolExecutor 子类的构造函数

constructor for ThreadPoolExecutor subclass

如果我扩展 ThreadPoolExecutor,有什么方法可以重用工厂方法,例如:

public static ExecutorService newSingleThreadExecutor()

或者我是否必须调用 ThreadPoolExecutor 子类的构造函数并输入所有参数:

class MyThreadPoolExecutor extends ThreadPoolExecutor {
  ...
  public MyThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) {
    super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
  };
  ...
}

没有办法做第一个。我建议换一种方式:

class MyThreadPoolExecutor extends ThreadPoolExecutor {
  ...
  public MyThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) {
    super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
  };
  ...
}

因为这是唯一的方法。