线程池注入:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
/** @Auther: Administrator @Date: 2020/3/31 11:56 @Description: AsyncConfig @Version 1.0 */
@Configuration
@EnableAsync
public class AsyncConfig implements AsyncConfigurer {
@Bean("defaultThreadPool")
public ThreadPoolTaskExecutor defaultThreadPool() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
// 核心线程数目
executor.setCorePool