package cn.fw.valhalla.common.utils; import cn.hutool.core.thread.ExecutorBuilder; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; /** * ThreadPoolUtl * * @author : kurisu * @version : 2.0 * @className : ThreadPoolUtl * @description : ThreadPoolUtl * @date : 2023-04-19 17:31 */ public class ThreadPoolUtil { private static volatile ThreadPoolUtil INSTANCE; private final ExecutorService executor; private ThreadPoolUtil() { this.executor = ExecutorBuilder.create() .setCorePoolSize(20) .setMaxPoolSize(60) .setWorkQueue(new LinkedBlockingQueue<>(4096)) .build(); } public static ThreadPoolUtil getInstance() { if (INSTANCE == null) { synchronized (ThreadPoolUtil.class) { if (INSTANCE == null) { INSTANCE = new ThreadPoolUtil(); } } } return INSTANCE; } public ExecutorService getExecutor() { return executor; } }