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

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

線程類不能直接調(diào)用方法,必須使用構(gòu)造方法嗎?下面兩個例子運行有什么不同

線程類不能直接調(diào)用方法,必須使用構(gòu)造方法嗎?下面兩個例子運行有什么不同

超人TT 2016-07-29 16:40:49
1.public?class?DieThreadDemo?{ public?static?void?main(String[]?args)?{ Example?example=new?Example(); helloThread1?thread1=new?helloThread1(example); thread1.start(); helloThread2?thread2=new?helloThread2(example); thread2.start(); } } class?helloThread1?extends?Thread{ private?Example?example=null; public?helloThread1(Example?example){ this.example=example; } @Override public?void?run()?{ example.method1(); } } 2.public?class?hello?{ public?static?void?main(String[]?args)?{ helloThread1?thread1=new?helloThread1(); thread1.start(); helloThread2?thread2=new?helloThread2(); thread2.start(); } } class?helloThread1?extends?Thread{ Example?example=new?Example(); public?void?run(){ example.method1(); } }
查看完整描述

1 回答

?
風(fēng)一般的男人

TA貢獻(xiàn)6條經(jīng)驗 獲得超3個贊

java里面是new Thread().start(),就是都是先實例化類,在調(diào)用run()方法,然后再通過run()方法調(diào)用其他方法。

不同之處在于,第一種可以向子線程傳值,而第二種不能傳值,因為第二種線程的構(gòu)造方法只有空的構(gòu)造方法。

查看完整回答
反對 回復(fù) 2016-08-01
  • 1 回答
  • 0 關(guān)注
  • 1355 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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