diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalThreadPoolManage.java b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalThreadPoolManage.java index 0d09fab9..a511db10 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalThreadPoolManage.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/executor/manage/GlobalThreadPoolManage.java @@ -23,7 +23,9 @@ import com.google.common.collect.Lists; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ThreadPoolExecutor; /** * Global thread-pool manage. @@ -53,6 +55,16 @@ public class GlobalThreadPoolManage { return EXECUTOR_MAP.get(threadPoolId); } + /** + * Get the dynamic thread pool wrapper class. + * + * @param threadPoolId + * @return + */ + public static ThreadPoolExecutor getExecutor(String threadPoolId) { + return Optional.ofNullable(EXECUTOR_MAP.get(threadPoolId)).map(each -> each.getExecutor()).orElse(null); + } + /** * Get dynamic thread pool parameters. * @@ -106,7 +118,7 @@ public class GlobalThreadPoolManage { /** * Get the number of dynamic thread pools. - * + *

* The data may be inaccurate when the project is initially * launched because registration is done asynchronously. *