[问题]
有线程 T1,T2,T3,T4 如何实现线程依照 T1-T4 程序运行?
[代码]
public static void main(String[] args) {final FutureTask<Integer> ft1 = new FutureTask<>(()-> {System.out.println("ft1");
return 1;
});
final FutureTask<Integer> ft2 = new FutureTask(()-> {ft1.get();
System.out.println("ft2");
return 1;
});
final FutureTask<Integer> ft3 = new FutureTask(()-> {ft2.get();
System.out.println("ft3");
return 1;
});
final FutureTask<Integer> ft4 = new FutureTask(()-> {ft3.get();
System.out.println("ft4");
return 1;
});
new Thread(ft1).start();
new Thread(ft2).start();
new Thread(ft3).start();
new Thread(ft4).start();}