From 8315ad7e5af7f5e290010ef7bc2e40ada06b5a14 Mon Sep 17 00:00:00 2001 From: wulang Date: Mon, 24 Oct 2022 19:03:11 +0800 Subject: [PATCH] feat:The core thread must not be larger than the maximum thread. --- .../cn/hippo4j/core/executor/support/ThreadPoolBuilder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java index e54d8e73..7680b9d4 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/support/ThreadPoolBuilder.java @@ -112,6 +112,9 @@ public class ThreadPoolBuilder implements Builder { public ThreadPoolBuilder maxPoolNum(int maxPoolSize) { this.maxPoolSize = maxPoolSize; + if (maxPoolSize < this.corePoolSize) { + this.corePoolSize = maxPoolSize; + } return this; } @@ -228,6 +231,7 @@ public class ThreadPoolBuilder implements Builder { /** * Create dynamic thread pool by thread pool id + * * @param threadPoolId threadPoolId * @return ThreadPoolExecutor */