From 3768d65a6e1beb5f9e298292ed9607cb5fffce31 Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Mon, 1 Nov 2021 21:16:47 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E4=BC=98=E5=8C=96=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/config/ThreadPoolConfig.java | 18 +++++++++--------- .../example/inittest/AlarmSendMessageTest.java | 6 +++--- .../example/inittest/RunStateHandlerTest.java | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java b/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java index 6d3ec6c6..a21dd8bd 100644 --- a/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java +++ b/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java @@ -1,9 +1,9 @@ package com.github.dynamic.threadpool.example.config; import com.github.dynamic.threadpool.starter.core.DynamicThreadPool; -import com.github.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor; +import com.github.dynamic.threadpool.starter.core.DynamicThreadPoolExecutor; import com.github.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder; -import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; +import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -23,26 +23,26 @@ import static com.github.dynamic.threadpool.example.constant.GlobalTestConstant. public class ThreadPoolConfig { /** - * {@link DynamicThreadPoolWrap} 完成 Server 端订阅配置功能. + * {@link DynamicThreadPoolWrapper} 完成 Server 端订阅配置功能. * * @return */ @Bean - public DynamicThreadPoolWrap messageCenterConsumeThreadPool() { - return new DynamicThreadPoolWrap(MESSAGE_CONSUME); + public DynamicThreadPoolWrapper messageCenterDynamicThreadPool() { + return new DynamicThreadPoolWrapper(MESSAGE_CONSUME); } /** - * 通过 {@link DynamicThreadPool} 修饰 {@link CustomThreadPoolExecutor} 完成 Server 端订阅配置功能. + * 通过 {@link DynamicThreadPool} 修饰 {@link DynamicThreadPoolExecutor} 完成 Server 端订阅配置功能. *

- * 由动态线程池注解修饰后, IOC 容器中保存的是 {@link CustomThreadPoolExecutor} + * 由动态线程池注解修饰后, IOC 容器中保存的是 {@link DynamicThreadPoolExecutor} * * @return */ @Bean @DynamicThreadPool - public ThreadPoolExecutor customThreadPoolExecutor() { - return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).isCustomPool(true).build(); + public ThreadPoolExecutor dynamicThreadPoolExecutor() { + return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).dynamicPool().build(); } } diff --git a/example/src/main/java/com/github/dynamic/threadpool/example/inittest/AlarmSendMessageTest.java b/example/src/main/java/com/github/dynamic/threadpool/example/inittest/AlarmSendMessageTest.java index 73243045..eb4918fb 100644 --- a/example/src/main/java/com/github/dynamic/threadpool/example/inittest/AlarmSendMessageTest.java +++ b/example/src/main/java/com/github/dynamic/threadpool/example/inittest/AlarmSendMessageTest.java @@ -2,7 +2,7 @@ package com.github.dynamic.threadpool.example.inittest; import cn.hutool.core.thread.ThreadUtil; import com.github.dynamic.threadpool.starter.core.GlobalThreadPoolManage; -import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; +import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -28,8 +28,8 @@ public class AlarmSendMessageTest { public void alarmSendMessageTest() { ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor(); scheduledThreadPool.scheduleWithFixedDelay(() -> { - DynamicThreadPoolWrap executorService = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE); - ThreadPoolExecutor poolExecutor = executorService.getPool(); + DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE); + ThreadPoolExecutor poolExecutor = poolWrapper.getPool(); try { poolExecutor.execute(() -> ThreadUtil.sleep(10240124)); } catch (Exception ex) { diff --git a/example/src/main/java/com/github/dynamic/threadpool/example/inittest/RunStateHandlerTest.java b/example/src/main/java/com/github/dynamic/threadpool/example/inittest/RunStateHandlerTest.java index 85d49c9b..31867c5d 100644 --- a/example/src/main/java/com/github/dynamic/threadpool/example/inittest/RunStateHandlerTest.java +++ b/example/src/main/java/com/github/dynamic/threadpool/example/inittest/RunStateHandlerTest.java @@ -1,7 +1,7 @@ package com.github.dynamic.threadpool.example.inittest; import com.github.dynamic.threadpool.starter.core.GlobalThreadPoolManage; -import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap; +import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -30,8 +30,8 @@ public class RunStateHandlerTest { ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor(); scheduledThreadPool.scheduleAtFixedRate(() -> { - DynamicThreadPoolWrap executorService = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE); - ThreadPoolExecutor pool = executorService.getPool(); + DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE); + ThreadPoolExecutor pool = poolWrapper.getPool(); try { pool.execute(() -> { log.info("Thread pool name :: {}, Executing incoming blocking...", Thread.currentThread().getName());