重构全局动态线程池管理容器.

pull/28/head
chen.ma 3 years ago
parent f3f2c9378d
commit ac30c14f75

@ -16,33 +16,85 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class GlobalThreadPoolManage {
/**
* 线
*/
private static final Map<String, PoolParameter> POOL_PARAMETER = new ConcurrentHashMap();
/**
* 线
*/
private static final Map<String, DynamicThreadPoolWrapper> EXECUTOR_MAP = new ConcurrentHashMap();
public static DynamicThreadPoolWrapper getExecutorService(String tpId) {
return EXECUTOR_MAP.get(tpId);
/**
* 线.
*
* @param threadPoolId
* @return
*/
public static DynamicThreadPoolWrapper getExecutorService(String threadPoolId) {
return EXECUTOR_MAP.get(threadPoolId);
}
public static PoolParameter getPoolParameter(String tpId) {
return POOL_PARAMETER.get(tpId);
/**
* 线.
*
* @param threadPoolId
* @return
*/
public static PoolParameter getPoolParameter(String threadPoolId) {
return POOL_PARAMETER.get(threadPoolId);
}
public static void register(String tpId, PoolParameter poolParameter, DynamicThreadPoolWrapper executor) {
registerPool(tpId, executor);
registerPoolParameter(tpId, poolParameter);
/**
* 线.
*
* @param threadPoolId
* @param poolParameter
* @param executor
*/
public static void register(String threadPoolId, PoolParameter poolParameter, DynamicThreadPoolWrapper executor) {
registerPool(threadPoolId, executor);
registerPoolParameter(threadPoolId, poolParameter);
}
public static void registerPool(String tpId, DynamicThreadPoolWrapper executor) {
EXECUTOR_MAP.put(tpId, executor);
/**
* 线.
*
* @param threadPoolId
* @param executor
*/
public static void registerPool(String threadPoolId, DynamicThreadPoolWrapper executor) {
EXECUTOR_MAP.put(threadPoolId, executor);
}
public static void registerPoolParameter(String tpId, PoolParameter poolParameter) {
POOL_PARAMETER.put(tpId, poolParameter);
/**
* 线.
*
* @param threadPoolId
* @param poolParameter
*/
public static void registerPoolParameter(String threadPoolId, PoolParameter poolParameter) {
POOL_PARAMETER.put(threadPoolId, poolParameter);
}
/**
* 线.
*
* @return
*/
public static List<String> listThreadPoolId() {
return Lists.newArrayList(POOL_PARAMETER.keySet());
}
/**
* 线.
* , .
*
* @return
*/
public static Integer getThreadPoolNum() {
return listThreadPoolId().size();
}
}

Loading…
Cancel
Save