一、ThreadPoolTaskExecutor和ThreadPoolExecutor有何区别?
ThreadPoolTaskExecutor是spring core包中的,而ThreadPoolExecutor是JDK中的JUC,ThreadPoolTaskExecutor是对ThreadPoolExecutor进行了封装处理。祖类都是调用Executor接口。
(Executor 顾名思义是专门用来处理多线程相关的一个接口,所有线程相关的类都实现了这个接口)
从源码可知,ThreadPoolTaskExecutor的实现方式完全是使用threadPoolExecutor进行实现
这是ThreadPoolTaskExecutor用来初始化threadPoolExecutor的方法:
public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport implements SchedulingTaskExecutor {
private final Object poolSizeMonitor = new Object();
private int corePoolSize = 1;
private int maxPoolSize = 2147483647;
private int keepAliveSeconds = 60;
private boolean allowCoreThreadTimeOut = false;
private int queueCapacity = 2147483647;
private ThreadPoolExecutor threadPoolExecutor; //这里就用到了ThreadPoolExecutor
二、
.....待更新