@Test
public void test1() throws ExecutionException, InterruptedException {
//创建线城实例
MaxNum m = new MaxNum(3, 5, 7);
//创建FutrueTask实例
FutureTask<Integer> ft = new FutureTask<Integer>(m);
Thread thread = new Thread(ft);
thread.start();
System.out.println("最大的数为:" + ft.get());
}
class MaxNum implements Callable<Integer> {
int i, j, k;
public MaxNum(int i, int j, int k) {
this.i = i;
this.j = j;
this.k = k;
}
@Override
public Integer call() throws Exception {
return Math.max(Math.max(i, j), k);
}
}
#学习路径#