线程池源码阅读(一)
线程池源码阅读(一) 仅大致过了下,有问题的请指出,谢谢。 版本 1.8 类关系 1. Executors 提供创建 ThreadPoolExecutor 类的快速方法。 建议:不要使用 Executors 类创建 ThreadPoolExecutor newFixedThreadPool newSingleThreadExecutor newCachedThreadPool newScheduledThreadPool public static ExecutorService newFixedThreadPool ( int nThreads ) { return new ThreadPoolExecutor ( nThreads , nThreads , 0 L , TimeUnit . MILLISECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ; } public static ExecutorService newFixedThreadPool ( int nThreads , ThreadFactory threadFactory ) { return new ThreadPoolExecutor ( nThreads , nThreads , 0 L , TimeUnit . MILLISECONDS ,