public class PostThread implements Callable { private String s; public PostThread (String str) { this.s = h; } public Object call() throws Exception { return this.s; } }
使用的时候:
ExecutorService pool = Executors.newFixedThreadPool(2); Callable c1 = new PostThread("hello"); Future f1 = pool.submit(c1);
String str = (String)f1.get();