Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Main { private static ExecutorService scheduler = null; private static Object syncRoot = new Object(); /** * Singleton access to the threadpool scheduler */ public static ExecutorService getScheduler() { synchronized (syncRoot) { if (null == scheduler) { scheduler = Executors.newCachedThreadPool(); } return scheduler; } } }