Skip to content

Instantly share code, notes, and snippets.

@nschlimm
Created March 22, 2012 10:12
Show Gist options
  • Save nschlimm/2157553 to your computer and use it in GitHub Desktop.
Save nschlimm/2157553 to your computer and use it in GitHub Desktop.
Executors thread pools
public static ExecutorService newCachedThreadPool() {
return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>());
}
public static ExecutorService newFixedThreadPool(int nThreads) {
return new ThreadPoolExecutor(nThreads, nThreads,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment