This commit is contained in:
dute7liang
2023-12-29 02:53:02 +08:00
parent 83d87d0927
commit 973c9545af
6 changed files with 130 additions and 24 deletions

View File

@@ -17,6 +17,7 @@ public class ExecutorConstant {
public static Executor SYNC_EXECUTOR;
public static Executor COMMON_EXECUTOR;
public static Executor ROOM_EXECUTOR;
static {
ThreadPoolExecutor syncExecutor = initExecutor(CPU_NUM,
@@ -36,6 +37,15 @@ public class ExecutorConstant {
new ThreadPoolExecutor.CallerRunsPolicy());
COMMON_EXECUTOR = TtlExecutors.getTtlExecutor(commonExecutor);
ThreadPoolExecutor roomExecutor = new ThreadPoolExecutor(CPU_NUM,
CPU_NUM << 2,
5,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(50),
init("roomThreadPoll-%d"),
new ThreadPoolExecutor.CallerRunsPolicy());
ROOM_EXECUTOR = TtlExecutors.getTtlExecutor(roomExecutor);
}
private static ThreadFactory init(String nameFormat){