class Test implements Callable<Integer>{
@Override
public Integer call() throws Exception {
System.out.println("Callable 方法执行了。。。");
TimeUnit.SECONDS.sleep(5);
return 1024;
}
}
class Main {
public static void main(String[] args) throws Exception{
FutureTask<Integer> integerFutureTask = new FutureTask<>(new Test());
Thread t1 = new Thread(integerFutureTask, "t1");
t1.start();
System.out.println("integerFutureTask.get()"+integerFutureTask.get());
}
}