Java5以后,出现有返回值的多线程。
实现方式:实现Callable接口,无返回值的实现Runnable接口。
import java.util.concurrent.Callable;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.Future;public class Test { public static void main(String[] args) throws Exception { ExecutorService pool = Executors.newFixedThreadPool(2); MyCallable c1 = new MyCallable("A"); MyCallable c2 = new MyCallable("B"); Future