Add get thread pool instance

pull/246/head
chen.ma 2 years ago
parent 046123f3a2
commit 3b8c1cdc6a

@ -23,7 +23,9 @@ import com.google.common.collect.Lists;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
/** /**
* Global thread-pool manage. * Global thread-pool manage.
@ -53,6 +55,16 @@ public class GlobalThreadPoolManage {
return EXECUTOR_MAP.get(threadPoolId); 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. * Get dynamic thread pool parameters.
* *
@ -106,7 +118,7 @@ public class GlobalThreadPoolManage {
/** /**
* Get the number of dynamic thread pools. * Get the number of dynamic thread pools.
* * <p>
* The data may be inaccurate when the project is initially * The data may be inaccurate when the project is initially
* launched because registration is done asynchronously. * launched because registration is done asynchronously.
* *

Loading…
Cancel
Save