1 | public ThreadPoolExecutor(int corePoolSize, |
2 | int maximumPoolSize, |
3 | long keepAliveTime, |
4 | TimeUnit unit, |
5 | BlockingQueue<Runnable> workQueue, |
6 | ThreadFactory threadFactory, |
7 | RejectedExecutionHandler handler) |
01 | public static ExecutorService newFixedThreadPool(int nThreads) { |
02 | return new ThreadPoolExecutor(nThreads, |
03 | nThreads, |
04 | 0L, |
05 | TimeUnit.MILLISECONDS, |
06 | newLinkedBlockingQueue<Runnable>()); |
07 | } |
08 |
09 | public static ExecutorService newCachedThreadPool() { |
10 | return new ThreadPoolExecutor(0, |
11 | Integer.MAX_VALUE, |
12 | 60L, |
13 | TimeUnit.SECONDS, |
14 | newSynchronousQueue<Runnable>()); |
15 | } |
16 |
17 | public static ExecutorService newSingleThreadExecutor() { |
18 | return new FinalizableDelegatedExecutorService(new ThreadPoolExecutor(1, |
19 | 1, |
20 | 0L, |
21 | TimeUnit.MILLISECONDS, |
22 | newLinkedBlockingQueue<Runnable>())); |