34 lines
974 B
Java
34 lines
974 B
Java
package com.shiyi.analysis.config;
|
|
|
|
import cn.hippo4j.core.executor.DynamicThreadPool;
|
|
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
/**
|
|
* @Description :
|
|
* @Author : YangHaoYu
|
|
* @Date: 2023-11-26 10:34
|
|
*/
|
|
@Configuration
|
|
public class ThreadPoolConfig {
|
|
@Bean
|
|
@DynamicThreadPool
|
|
public ThreadPoolExecutor aAnalysisThreadPool() {
|
|
// 创建一个分析线程池
|
|
String threadPoolId = "fate-analysis";
|
|
// 使用线程工厂和线程池ID创建线程池构建器
|
|
ThreadPoolExecutor threadPoolBuilder = ThreadPoolBuilder.builder()
|
|
.threadFactory(threadPoolId)
|
|
.threadPoolId(threadPoolId)
|
|
.dynamicPool()
|
|
.build();
|
|
// 返回线程池构建器
|
|
return threadPoolBuilder;
|
|
}
|
|
|
|
|
|
}
|