标签:常用 nbsp 一个 div 执行 pre 复用 png exec
1 /** 2 * new SingleThreadExecutor 核心线程一个、最大线程一个、创建后不销毁、无限队列 3 */ 4 private static void singleThreadPool() { 5 ExecutorService executor = Executors.newSingleThreadExecutor(); 6 for (int i = 0; i < 10; i++) { 7 executor.execute(new MyRunable(i)); 8 } 9 // 执行完后销毁线程池 10 executor.shutdown(); 11 }
1 /** 2 * new FixedThreadPool 核心线程和最大线程一样,创建后不销毁、无限队列 3 */ 4 private static void fixedThreadPool() { 5 int threadSize = 5; 6 ExecutorService executor = Executors.newFixedThreadPool(threadSize); 7 for (int i = 0; i < 15; i++) { 8 executor.execute(new MyRunable(i)); 9 } 10 // 执行完后销毁线程池 11 executor.shutdown(); 12 }
1 /** 2 * new CachedThreadPool 核心线程零个、最大线程无限、创建后60s无复用销毁、同步队列 3 */ 4 private static void cachedThreadPool() { 5 ExecutorService executor = Executors.newCachedThreadPool(); 6 for (int i = 0; i < 100; i++) { 7 executor.execute(new MyRunable(i)); 8 } 9 // 执行完后销毁线程池 10 executor.shutdown(); 11 }
标签:常用 nbsp 一个 div 执行 pre 复用 png exec
原文地址:https://www.cnblogs.com/jtfr/p/10187419.html