package Thread.createThread; import java.util.ArrayList; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; public class ExecutorTest { public static void cachedThreadPoolTest(){ // 1.线程池的newCachedThreadPool ExecutorService executorService = Executors.newCachedThreadPool(); for (int i = 0; i > results=new ArrayList>(); for(int i=0;i future:results){ try { //get()方法将会被阻塞,直到完成 System.out.println(future.get()); } catch (InterruptedException | ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public static void main(String[] args) { cachedThreadPoolTest(); //fixedThreadPoolTest(); //singleThreadExecutor(); /*for(int i=0;i