public class CallableDemo
{
public static void main(String[] args) throws InterruptedException, ExecutionException
{
FutureTask<Integer> ft = new FutureTask<Integer>(new MyThread());
new Thread(ft, "AA").start();
new Thread(ft, "BB").start();
System.out.println(Thread.currentThread().getName()+"***********我是上课主线程");
Integer result01 = ft.get();
System.out.println("******result01: "+result01);
}
}
class MyThread implements Callable<Integer>
{
@Override
public Integer call() throws Exception
{
System.out.println("**********call() ****");
//Thread.sleep(4000);
return 1018;
}
}