@@ -0,0 +1,1130 @@
+package amery.jdk.concurrent;%0A%0Aimport java.util.concurrent.*;%0A%0Apublic class ThreadPoolExecutorTest %7B%0A%0A%09//https://www.toutiao.com/i6597175542317842951/%0A%0A%0A%09public static ExecutorService newCachedThreadPool() %7B%0A%0A%09%09return new ThreadPoolExecutor(0, Integer.MAX_VALUE,%0A%0A%09%09%0960L, TimeUnit.SECONDS,%0A%0A%09%09%09new SynchronousQueue%3CRunnable%3E());%0A%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09//cache();%0A%09%09schedule();%0A%09%7D%0A%0A%09public static void schedule() %7B%0A%0A%09%09ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(5);%0A%0A%09%09scheduledThreadPool.scheduleAtFixedRate(new Runnable() %7B%0A%0A%09%09%09public void run() %7B%0A%0A%09%09%09%09System.out.println(%22delay 1 seconds, and excute every 3 seconds%22);%0A%0A%09%09%09%7D%0A%0A%09%09%7D, 1, 3, TimeUnit.SECONDS);%0A%0A%09%7D%0A%0A%09private static void cache() %7B%0A%09%09ExecutorService cachedThreadPool = Executors.newCachedThreadPool();%0A%0A%09%09for (int i = 0; i %3C 10; i++) %7B%0A%0A%09%09%09final int index = i;%0A%0A%09%09%09try %7B%0A%0A%09%09%09%09Thread.sleep(index * 1000);%0A%0A%09%09%09%7D catch (InterruptedException e) %7B%0A%0A%09%09%09%09e.printStackTrace();%0A%0A%09%09%09%7D%0A%0A%09%09%09cachedThreadPool.execute(new Runnable() %7B%0A%0A%09%09%09%09public void run() %7B%0A%0A%09%09%09%09%09System.out.println(index);%0A%0A%09%09%09%09%7D%0A%0A%09%09%09%7D);%0A%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

add test