/** * * Java线程:有返回值的线程 * @author wb_qiuquan.ying */ @SuppressWarnings("unchecked") public class Test { @SuppressWarnings("rawtypes") public static void main(String[] args) throws ExecutionException, InterruptedException { int sizeNum = 5; // 创建一个线程池 ExecutorService pool = Executors.newFixedThreadPool(sizeNum); // 创建多个有返回值的任务 List<Future> list = new ArrayList<Future>(); for (int i = 0; i < sizeNum; i++) { //Callable c = new MyCallable(i + " ");也可以这样写,运行结果一样 MyCallable c = new MyCallable(i + " ");