现有:classWaitingimplementsRunnable{

题目

现有:

classWaitingimplementsRunnable{

booleanflag=false;

publicsynchronizedvoidrun(){

if(flag){

flag=false;

System.out.print("1");

try{this.wait();)catch(Exceptione){}

System.out.print("2");

}

else{

flag=true;

System.out.print("3");

try{Thread.sleep(2000);}catch(Exceptione){}

System.out.print("4");

notify();

}

}

publicstaticvoidmain(String[]args){

Waitingw=newWaiting();

newThread(w).start();

newThread(w).start();

}

}

以下哪两项是正确的?()

更多“现有:classWaitingimplementsRunnable{ ”相关问题