IRVLIN
2019-12-04 11:45
public class Stage extends Thread { @Override public void run() { // TODO Auto-generated method stub Army suiArmyTask = new Army(); Army rebelArmyTask = new Army(); Thread suiArmy = new Thread(suiArmyTask, "隋军"); Thread rebelArmy = new Thread(rebelArmyTask, "起义军"); suiArmy.start(); rebelArmy.start(); try { Thread.sleep(5); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } suiArmyTask.keepFighting = false; rebelArmyTask.keepFighting = false; try { rebelArmy.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}
放到前面就不会停止是指哪个线程不会停止
深入浅出Java多线程
186088 学习 · 464 问题
相似问题