ThreadPoolExecutor
demo:
public class ThreadPoolExecutorTest { public static void main(String[] args) { Thread t = new Thread(() -> System.out.println("start...")); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 2, 1000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); threadPoolExecutor.execute(t); } }
分析: