package ink.wgink.util.thread; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.ExecutorService; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** * @ClassName: CachedThreadPoolUtil * @Description: 缓存线程池 * @Author: wanggeng * @Date: 2022/5/20 00:27 * @Version: 1.0 */ public class CachedThreadPoolUtil { private static final Logger LOG = LoggerFactory.getLogger(CachedThreadPoolUtil.class); /** * 最多66个线程,保持60s */ private static ExecutorService executorService = new ThreadPoolExecutor(0, 66, 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); /** * 执行线程 * * @param runnable */ public static void execute(Runnable runnable) { LOG.debug("****************** execute"); executorService.execute(runnable); } }