SpringBoot中引入多线程
@Async("threadPoolTaskExecutor")
public List<GetPayProjectListVo> getPrivateProject(Page page, DeliveryStatisticSqueryDto dto) {
return pmProjectInfoMapper.getPrivateProjectList(page, dto, system, activiti, oa);
}
@Resource
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@PostConstruct
public void init() {
ThreadPoolTaskExecutor threadPoolTaskExecutor=new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setCorePoolSize(4);
threadPoolTaskExecutor.setKeepAliveSeconds(10);
threadPoolTaskExecutor.setMaxPoolSize(10);
threadPoolTaskExecutor.setQueueCapacity(10);
threadPoolTaskExecutor.setThreadNamePrefix("task %d");
threadPoolTaskExecutor.initialize();
}
锦瑟流年,花开花落。