Here you can find the source of createDefaultExecutorService(final String threadNamePrefix, final int parallel)
Parameter | Description |
---|---|
threadNamePrefix | prefix of the thread name |
parallel | the number of concurrency |
static public ThreadPoolExecutor createDefaultExecutorService(final String threadNamePrefix, final int parallel)
//package com.java2s; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; public class Main { /**/* w w w . j a va 2s . c o m*/ * Returns a new thread pool configured with the default settings. * * @param threadNamePrefix prefix of the thread name * @param parallel the number of concurrency * @return A new thread pool configured with the default settings. */ static public ThreadPoolExecutor createDefaultExecutorService(final String threadNamePrefix, final int parallel) { ThreadFactory threadFactory = new ThreadFactory() { private int threadCount = 1; public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName(threadNamePrefix + threadCount++); return thread; } }; return (ThreadPoolExecutor) Executors.newFixedThreadPool(parallel, threadFactory); } }