From 4db3a16a3691082d42c5e1b8ef3bc11a265081f0 Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Fri, 9 Aug 2024 15:03:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/thread/ThreadPoolExecutorUtil.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/config/thread/ThreadPoolExecutorUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/config/thread/ThreadPoolExecutorUtil.java index 00c1bfe..49a46d8 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/config/thread/ThreadPoolExecutorUtil.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/config/thread/ThreadPoolExecutorUtil.java @@ -16,7 +16,11 @@ package org.nl.config.thread; -import org.nl.config.SpringContextHolder; +import org.dromara.dynamictp.core.support.DynamicTp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -27,16 +31,22 @@ import java.util.concurrent.TimeUnit; * @author Zheng Jie * @date 2019年10月31日18:16:47 */ +@Configuration public class ThreadPoolExecutorUtil { - public static ThreadPoolExecutor getPoll(){ - AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class); + @Autowired + private AsyncTaskProperties asyncTaskProperties; + + @Bean + @Primary + @DynamicTp("el-thread") + public ThreadPoolExecutor threadPoolExecutor() { return new ThreadPoolExecutor( - properties.getCorePoolSize(), - properties.getMaxPoolSize(), - properties.getKeepAliveSeconds(), + asyncTaskProperties.getCorePoolSize(), + asyncTaskProperties.getMaxPoolSize(), + asyncTaskProperties.getKeepAliveSeconds(), TimeUnit.SECONDS, - new ArrayBlockingQueue<>(properties.getQueueCapacity()), + new ArrayBlockingQueue<>(asyncTaskProperties.getQueueCapacity()), new TheadFactoryName() ); }