亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求大神指教

求大神指教

qq電子時代 2016-04-19 14:18:20
package com.Thread;import sun.rmi.runtime.Log;public class Thread0202 extends Thread { public void run() { Thread0201 t1 = new Thread0201(); Thread0201 t2 = new Thread0201(); // 使用Runnable接口創建線程 Thread one = new Thread(new Thread0201(), "one"); Thread two = new Thread(new Thread0201(), "two"); one.start(); two.start(); // 為什么start一開始 下面的命令不會執行 而且廝殺過程一直不會停止 try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } t1.i = false; t2.i = false; try { two.join(); } catch (InterruptedException e) { e.printStackTrace(); } } public static void main(String[] args) { new Thread0202().start(); }}
查看完整描述

1 回答

已采納
?
qq_青棗工作室_0

TA貢獻446條經驗 獲得超754個贊

因為你start的線程沒有用到t1和t2啊。

//?使用Runnable接口創建線程
Thread?one?=?new?Thread(new?Thread0201(),?"one");????//?這里你new了一個Thread0201,應該用t1
Thread?two?=?new?Thread(new?Thread0201(),?"two");??//?這里你new了一個Thread0201,應該用t2


查看完整回答
1 反對 回復 2016-04-19
  • 1 回答
  • 0 關注
  • 1915 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號