import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; public class FutureTest { public static void main(String s[]){ FutureTask<Integer> future1 = new FutureTask<Integer>(new Test1()); FutureTask<String> future2 = new FutureTask<String>(new Test2()); FutureTask<Long> future3 = new FutureTask<Long>(new Test3()); new Thread(future1).start(); new Thread(future2).start(); new Thread(future3).start(); try { if (future1.isDone()){ System.out.println("future1 is Done"); } if (future2.isDone()){ System.out.println("future2 is Done"); } if (future3.isDone()){ System.out.println("future3 is Done"); } int i = future1.get(); String str = future2.get(); long l = future3.get(); System.out.println(i+str+l); }catch (Exception e){ e.printStackTrace(); } } } class Test1 implements Callable<Integer>{ @Override public Integer call() { try { Thread.sleep(1000); }catch (Exception e){ } return 1; } } class Test2 implements Callable<String>{ @Override public String call() { try { Thread.sleep(5000); }catch (Exception e){ } return "2"; } } class Test3 implements Callable<Long>{ @Override public Long call() { try { Thread.sleep(10000); }catch (Exception e){ } return 3L; } }