You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
package com.bfd.crawl.ppthandler.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;
|
|
|
|
/**
|
|
* @author jinming
|
|
* @version 1.0
|
|
* @className AsyncThreadConfiguration
|
|
* @Date 2022/2/17 18:37
|
|
*/
|
|
@Configuration
|
|
@EnableAsync
|
|
public class AsyncThreadConfiguration {
|
|
@Bean
|
|
public Executor asyncExecutor() {
|
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
// 核心线程数
|
|
executor.setCorePoolSize(500);
|
|
// 并发线程的数量限制为2
|
|
executor.setMaxPoolSize(500);
|
|
// 线程队列
|
|
executor.setQueueCapacity(500);
|
|
executor.setThreadNamePrefix("handlerData-");
|
|
executor.initialize();
|
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
|
return executor;
|
|
}
|
|
@Bean
|
|
public Executor sendExecutor() {
|
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
// 核心线程数
|
|
executor.setCorePoolSize(500);
|
|
// 并发线程的数量限制为2
|
|
executor.setMaxPoolSize(500);
|
|
// 线程队列
|
|
executor.setQueueCapacity(500);
|
|
executor.setThreadNamePrefix("sendData-");
|
|
executor.initialize();
|
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
|
return executor;
|
|
}
|
|
}
|