@Async(“name”)
在使用异步注解时需要配置默认线程池
自定义配置文件实现AsyncConfigurer并实现getAsyncExecutor方法和AsyncUncaughtExceptionHandler方法 在类上添加@EnableAsync
getAsyncExecutor方法配置参数设置
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(2); //核心线程数
taskExecutor.setMaxPoolSize(10);//线程池维护线程的最大数量,只有在缓冲队列满了之后才会申请超过核心线程数的线程
taskExecutor.setQueueCapacity(50);//缓存队列
taskExecutor.initialize();