package com.wdwl.changfa.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.annotation.EnableAsync;import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;import java.util.concurrent.Executor;@Configuration@EnableAsyncpublic class OneTaskPoolConfig { @Bean("oneTaskExecutor") public Executor taskExecutro(){ ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); //线程池维护线程的最少数量 taskExecutor.setCorePoolSize(10); //线程池维护线程的最大数量 taskExecutor.setMaxPoolSize(100); //线程池所使用的缓冲队列 taskExecutor.setQueueCapacity(10000); //线程池维护线程所允许的空闲时间 taskExecutor.setKeepAliveSeconds(60); taskExecutor.setAllowCoreThreadTimeOut(true); taskExecutor.setThreadNamePrefix("oneTaskExecutor--"); taskExecutor.setWaitForTasksToCompleteOnShutdown(true); taskExecutor.setAwaitTerminationSeconds(60); return taskExecutor; }} package com.wdwl.changfa.service.impl;import com.alibaba.fastjson.JSON;import com.wdwl.changfa.mapper.TbStudentMapper;import com.wdwl.changfa.model.TbStudent;import com.wdwl.changfa.service.IAsyncTaskService;import lombok.extern.slf4j.Slf4j;import org.jsoup.Connection;import org.jsoup.Jsoup;import org.jsoup.nodes.Element;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.scheduling.annotation.Async;import org.springframework.stereotype.Service;import java.io.IOException;@Service@Slf4jpublic class AsyncTaskServiceImpl implements IAsyncTaskService { @Autowired private TbStudentMapper studentMapper; @Override @Async("oneTaskExecutor") public void start(TbStudent student) throws IOException { log.debug(Thread.currentThread().getName()); }}