第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

死循環(huán),怎么破?

package com.thread;


/**

?* 隋唐演義作戰(zhàn)舞臺(tái)

?*/

public class Stage extends Thread {

public void run(){

System.out.println("隋唐演義馬上開(kāi)始,請(qǐng)保持安靜");

try {

Thread.sleep(5000);

} catch (InterruptedException e1) {

e1.printStackTrace();

}

//創(chuàng)建軍隊(duì)任務(wù)

ArmyRunnable armyTaskOfSuiTang = new ArmyRunnable();

ArmyRunnable armyTaskOfFarmmer = new ArmyRunnable();

//使用Runnable接口,創(chuàng)建軍隊(duì)線程

Thread armyOfSuiTang = new Thread(new ArmyRunnable(),"隋軍");

Thread armyOfFarmmer = new Thread(new ArmyRunnable(),"農(nóng)民軍");

//啟動(dòng)線程,讓軍隊(duì)開(kāi)始作戰(zhàn)

armyOfSuiTang.start();

armyOfFarmmer.start();

//舞臺(tái)線程休眠

try {

Thread.sleep(50);

} catch (InterruptedException e) {

e.printStackTrace();

}

//半路殺出個(gè)程咬金

System.out.println("正當(dāng)雙方打得正酣,半路殺出來(lái)一個(gè)程咬金,隋軍猝不及防!");

Thread Cheng = new KeyPersonThread();

Cheng.setName("陳咬金");

System.out.println("陳咬金見(jiàn)不得隋軍猖狂!");

//停止軍隊(duì)線程作戰(zhàn)

armyTaskOfSuiTang.keepRunning = false;

? ? ? armyTaskOfFarmmer.keepRunning = false;

? ? ?

? ? ? try {

Thread.sleep(2000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

? ? ?

? ? ? //等待關(guān)鍵人物完成任務(wù)

? ? ? Cheng.start();

? ? ? try {

Cheng.join();

} catch (InterruptedException e) {

e.printStackTrace();

}

? ?

? ? ? System.out.println("戰(zhàn)爭(zhēng)結(jié)束!");

? ? ? System.out.println("謝謝觀眾觀看,可以離場(chǎng)!");

}


public static void main(String[] args) {

new Stage().start();


}


}


正在回答

1 回答

輸出效果呢?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

死循環(huán),怎么破?

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)