From db5806f0e86ffe92f8fc2fedfc392554129178b2 Mon Sep 17 00:00:00 2001 From: Looly Date: Sun, 30 Jun 2024 17:59:16 +0800 Subject: [PATCH] =?UTF-8?q?ThreadUtil.newExecutor=E7=AD=89=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=8F=98=E6=9B=B4=E6=96=B9=E6=B3=95=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=80=BC=E5=8F=98=E6=9B=B4=E4=B8=BA?= =?UTF-8?q?ThreadPoolExecutor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../main/java/cn/hutool/core/thread/ThreadUtil.java | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2fcfa734..306586d20 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * 【cache 】 Cache.put变更策略,对于替换的键值对,不清理队列(issue#3618@Github) * 【core 】 添加 Windows 资源管理器风格字符串比较器(pr#3620@Github) * 【core 】 Week.of支持中文名称(issue#3637@Github) +* 【core 】 ThreadUtil.newExecutor等方法变更方法签名,返回值变更为ThreadPoolExecutor(pr#1230@Gitee) ### 🐞Bug修复 * 【core 】 修复AnnotationUtil可能的空指针错误 diff --git a/hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java b/hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java index 75f3281cb..57bb7de62 100644 --- a/hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/thread/ThreadUtil.java @@ -54,7 +54,7 @@ public class ThreadUtil { * * @return ExecutorService */ - public static ExecutorService newExecutor() { + public static ThreadPoolExecutor newExecutor() { return ExecutorBuilder.create().useSynchronousQueue().build(); } @@ -102,7 +102,7 @@ public class ThreadUtil { * @return {@link ThreadPoolExecutor} * @since 5.4.1 */ - public static ExecutorService newExecutor(int corePoolSize, int maximumPoolSize, int maximumQueueSize) { + public static ThreadPoolExecutor newExecutor(int corePoolSize, int maximumPoolSize, int maximumQueueSize) { return ExecutorBuilder.create() .setCorePoolSize(corePoolSize) .setMaxPoolSize(maximumPoolSize) @@ -147,7 +147,7 @@ public class ThreadUtil { * @author luozongle * @since 5.8.0 */ - public static ExecutorService newFixedExecutor(int nThreads, String threadNamePrefix, boolean isBlocked) { + public static ThreadPoolExecutor newFixedExecutor(int nThreads, String threadNamePrefix, boolean isBlocked) { return newFixedExecutor(nThreads, 1024, threadNamePrefix, isBlocked); } @@ -167,7 +167,7 @@ public class ThreadUtil { * @author luozongle * @since 5.8.0 */ - public static ExecutorService newFixedExecutor(int nThreads, int maximumQueueSize, String threadNamePrefix, boolean isBlocked) { + public static ThreadPoolExecutor newFixedExecutor(int nThreads, int maximumQueueSize, String threadNamePrefix, boolean isBlocked) { return newFixedExecutor(nThreads, maximumQueueSize, threadNamePrefix, (isBlocked ? RejectPolicy.BLOCK : RejectPolicy.ABORT).getValue()); } @@ -187,7 +187,7 @@ public class ThreadUtil { * @author luozongle * @since 5.8.0 */ - public static ExecutorService newFixedExecutor(int nThreads, + public static ThreadPoolExecutor newFixedExecutor(int nThreads, int maximumQueueSize, String threadNamePrefix, RejectedExecutionHandler handler) {