
com.xxl.rpc.util.ThreadPoolUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xxl-rpc-core Show documentation
Show all versions of xxl-rpc-core Show documentation
A high performance, distributed RPC framework.
package com.xxl.rpc.util;
import java.util.concurrent.*;
/**
* @author xuxueli 2019-02-18
*/
public class ThreadPoolUtil {
/**
* make server thread pool
*
* @param serverType
* @return
*/
public static ThreadPoolExecutor makeServerThreadPool(final String serverType){
ThreadPoolExecutor serverHandlerPool = new ThreadPoolExecutor(
60,
300,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue(1000),
new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "xxl-rpc, "+serverType+"-serverHandlerPool-" + r.hashCode());
}
},
new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
throw new XxlRpcException("xxl-rpc "+serverType+" Thread pool is EXHAUSTED!");
}
}); // default maxThreads 300, minThreads 60
return serverHandlerPool;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy