weaver-hrm-salary/src/com/engine/salary/util/SalaryThreadPoolUtil.java

81 lines
3.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.engine.salary.util;
import org.apache.commons.lang3.StringUtils;
/**
* @description: 此线程池类只适用于Runnalbe接口不适用与Callable接口
* 如有callable业务需要请自行使用线程池创建并确定要关闭
* @author: xiajun
* @modified By: xiajun
* @date: Created in 1/25/22 4:23 PM
* @version:v1.0
*/
public class SalaryThreadPoolUtil {
// /**
// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)<br>
// * 线程池最大并发线程数默认为10,核心线程数为0<br>
// * 并发量、延时要求较低的功能,建议优先选用此方法,避免线程资源浪费<br>
// *
// * @param LocalRunnable 异步任务<br>
// */
// public static void execute(LocalRunnable LocalRunnable) {
// execute(ModulePoolEnum.OTHER, "default", ModulePoolEnum.OTHER.getMaxThread(), LocalRunnable);
// }
//
// /**
// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)<br>
// * FixedThreadPool 线程池最大并发线程数为maximunPoolSize,核心线程数与maximunPoolSize相同<br>
// * 并发量、延时要求高的功能,选用此方法,会保持一定的线程资源占用<br>
// * 也可以使用重载方法指定corePoolSize<maximunPoolSize<br>
// *
// * @param module 模块名称<br>
// * @param function 功能描述<br>
// * @param LocalRunnable 异步任务<br>
// */
// public static void fixedPoolExecute(ModulePoolEnum module, String function, LocalRunnable LocalRunnable) {
// execute(module, function, module.getMaxThread(), LocalRunnable);
// }
//
// /**
// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)<br>
// * 线程池最大并发线程数为maximunPoolSize<br>
// *
// * @param module 模块名称<br>
// * @param function 功能描述<br>
// * @param maximunPoolSize 最大线程数<br>
// * @param LocalRunnable 异步任务<br>
// */
// private static void execute(ModulePoolEnum module, String function, int maximunPoolSize, LocalRunnable LocalRunnable) {
// execute(module, function, maximunPoolSize, maximunPoolSize, LocalRunnable);
// }
//
// /**
// * 使用指定名称的线程池执行异步任务(线程池名称为module+function拼接生成)<br>
// * 线程池最大并发线程数为maximunPoolSize<br>
// *
// * @param module 模块名称<br>
// * @param function 功能描述<br>
// * @param corePoolSize 核心线程数(即线程池空闲时,仍保留的线程数)<br>
// * @param maximunPoolSize 最大线程数<br>
// * @param LocalRunnable 异步任务<br>
// */
// private static void execute(ModulePoolEnum module, String function, int corePoolSize, int maximunPoolSize, LocalRunnable LocalRunnable) {
// if (StringUtils.isEmpty(function)) {
// function = "default";
// }
// LocalRunnable.setFunctiondesc(function);
// LocalRunnable.setModule(module.name());
// ThreadPoolFactory.getExecutor(module, corePoolSize, maximunPoolSize).execute(LocalRunnable);
// }
//
// /**
// * 关闭指定的连接池,一般情况下不会使用,请勿随意调用<br>
// *
// * @param module 模块名称<br>
// */
// private void shutdown(ModulePoolEnum module) {
// ThreadPoolFactory.shutdownExecutor(module);
// }
}