方法上加注解@Async
启动类加注解@EnableAsync
了解到应该是开启16线程
怎么开启更多线程
新建类
@Configuration
public class ThreadPoolConfig {
@Bean
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(100); // 设置核心线程数
executor.setMaxPoolSize(100); // 设置最大线程数
executor.setQueueCapacity(50); // 设置队列容量
executor.setThreadNamePrefix("MyThread-"); // 设置线程名称前缀
executor.initialize();
return executor;
}
}