不过WAIT还是不怎么明白public class test extends Thread {private int i=0; public test(){} public void run(){ while (i<100){ try{ System.out.println(i); wait(1000); i++; System.out.println(i); }catch(Exception err){} } } public static void main(String args[]) throws java.io.IOException {test test1=new test(); test1.run();
而是while (i==100)呀
I==100本来就是FALSE
I==100本来就是FALSE
{private int i=0;
public test(){}
public void run(){
while (i<100){
try{
System.out.println(i);
wait(1000);
i++;
System.out.println(i);
}catch(Exception err){}
}
}
public static void main(String args[]) throws java.io.IOException
{test test1=new test();
test1.run();
}
}
好像吧能运行WAIT(1000)以前的,而且很快。
那么在test1.run以下的程序因为RUN没有完成而执行不完。那样的话,那部份中就算有notify();也运行不了。那我的WAIT怎么结束呀。
还有能不能说一下wait()的用法,比如wait()里的数是什么意思