java线程池工具类

public class ThreadPools {
    public static ExecutorService exec = new ThreadPoolExecutor(
            20,
            300,
            0L,
            TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue(1024),
            new ThreadFactory() {
                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r);
                }
            },
            new ThreadPoolExecutor.AbortPolicy());
}

使用

  ThreadPools.exec.execute(() -> {
                //调用方法
   });

 

你可能感兴趣的:(java工具类)