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

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

Thread actor=new Thread(new Actor(),"Mr.Thread");

為什么如題的代碼運(yùn)行結(jié)果不對(duì) 編譯器也不報(bào)錯(cuò)呢

正在回答

3 回答

package com.imooc.concurrent;


public class Actor extends Thread {


public void run() {

System.out.println(getName() + "is an actor");

int count = 0;

boolean a=true;

while (a){

System.out.println(getName() + "show begins" + (++count));

if (count==100)

{

a=false;

}

if(count%10==0){

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

// System.out.println(getName() + "show begins" + (++count));

System.out.println(getName() + "show is over");

}


public static void main(String[] args) {

// Thread actor = new Actor();

//

// actor.setName("Mr.Thread");

Thread actor=new Thread(new Actor(),"Mr.Thread");

actor.start();

Thread actressThread= new Thread(new Actress(),"Ms.Runnable");

actressThread.start();

}


}


?class Actress implements Runnable{

public void run() {

System.out.println(Thread.currentThread().getName() + "is an actor");

int count = 0;

boolean a=true;

while (a){

System.out.println(Thread.currentThread().getName() + "show begins" + (++count));

if (count==100)

{

a=false;

}

if(count%10==0){

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

// System.out.println(getName() + "show begins" + (++count));

System.out.println(Thread.currentThread().getName() + "show is over");

}

?}


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

Actor是否實(shí)現(xiàn)了Runable或繼承了Thread,run方法是否有問題

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

慕神1905738 提問者

代碼加進(jìn)來了 請(qǐng)看看是哪里的問題 謝謝
2016-10-25 回復(fù) 有任何疑惑可以回復(fù)我~

查看下 Actor類 是否實(shí)現(xiàn)了 runable接口

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

慕神1905738 提問者

代碼加進(jìn)來了 請(qǐng)幫忙看看是哪里的問題 謝謝
2016-10-25 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

Thread actor=new Thread(new Actor(),"Mr.Thread");

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

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

幫助反饋 APP下載

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

公眾號(hào)

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