public class Ruuu implements Runnable{
/**
* @param args
*/
private int cou = 5;
public String toString(){
return "#" + Thread.currentThread().getName() + ": " +cou;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=0;i<=5;i++)
new Thread(new Ruuu()," " + i).start();
}
public void run() {
// TODO Auto-generated method stub
while(true){
System.out.println(this);
if(--cou == 0) return;
}
}
if(--cou == 0) return;--表示什么意思啊?
參考答案:cou=cou-1 然后判断是否等于0 是则return