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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

在Daemon線程運(yùn)行中我在Eclipse Console 隨意輸入字符怎么沒有用啊

public?class?DaemonThreadDemo?{
/**
*?@param?args
*/
public?static?void?main(String[]?args)?{
System.out.println("進(jìn)入Main線程?"?+?Thread.currentThread().getName());
ThreadDaemon?daemonThread?=?new?ThreadDaemon();
Thread?t1?=?new?Thread(daemonThread,?"DaemonThread1");
t1.setDaemon(true);
t1.start();
Scanner?sc?=?new?Scanner(System.in);
sc.next();
System.out.println("退出Main線程?"?+?Thread.currentThread().getName());
}
}
class?ThreadDaemon?implements?Runnable?{
@Override
public?void?run()?{
System.out.println("進(jìn)入守護(hù)線程?"?+?Thread.currentThread().getName());
try?{
writeToFile();
}?catch?(Exception?e)?{
e.printStackTrace();
}
System.out.println("退出守護(hù)線程?"?+?Thread.currentThread().getName());
}
private?void?writeToFile()?throws?Exception?{
File?fileName?=?new?File("d:"?+?File.separator?+"JavaDameonThread.txt");
OutputStream?os?=?new?FileOutputStream(fileName,?true);
int?count?=?0;
while(count?<?100)?{
os.write(("\r\nHello?Java"?+?count).getBytes());
System.out.println("守護(hù)線程?"?+?Thread.currentThread().getName()
+?"向文件中寫了?Hello?Java?"?+?count++);
Thread.sleep(1000);
}
}
}


正在回答

1 回答

輸完字符后需要回車一下,才能讀取。試一下

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

舉報

0/150
提交
取消

在Daemon線程運(yùn)行中我在Eclipse Console 隨意輸入字符怎么沒有用啊

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

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

幫助反饋 APP下載

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

公眾號

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