Java tutorial
//package com.java2s; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class Main { private static ExecutorService executor; public static ExecutorService getThreadPoolExecutor() { if (executor == null) { executor = new ThreadPoolExecutor(2, 5, 60, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(3)); } return executor; } }