Commit 0634a7a8 by huangfusuper

Netty服务端 线程池创建器编码

parent 0de98b40
package com.byit.utils;
import com.byit.rpc.util.RpcException;
import java.util.concurrent.*;
/**
* 线程池创建工具
* @author huangfu
*/
public class ThreadPoolUtil {
/**
* 线程池创建
* @param serverType 服务名称
* @return 返回一个线程池
*/
public static ThreadPoolExecutor makeServerThreadPool(final String serverType, int corePoolSize, int maxPoolSize){
return new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(1000),
r -> new Thread(r, "myth-plugin-rpc, "+serverType+"-serverHandlerPool-" + r.hashCode()),
(r, executor) -> {
throw new RpcException("myth-plugin-rpc "+serverType+" Thread pool is EXHAUSTED!");
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment