package com.whyc.factory; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class ThreadPoolExecutorFactory { private static ThreadPoolExecutor poolExecutor = init(); private static ThreadPoolExecutor init() { //线程池初始化 UserThreadFactory userThreadFactory = new UserThreadFactory("bl"); ThreadPoolExecutor pool = new ThreadPoolExecutor(10, 48, 10, TimeUnit.SECONDS, new LinkedBlockingDeque<>(16), userThreadFactory,new ThreadPoolExecutor.CallerRunsPolicy()); poolExecutor = pool; return pool; } public static ThreadPoolExecutor getPoolExecutor() { return poolExecutor; } }