int i=0;
while (i<30)
{
System.out.println("HelloWorld");
try{
Thread.currentThread().sleep(1000);
}catch(Exception e){
}
}
while (i<30)
{
System.out.println("HelloWorld");
try{
Thread.currentThread().sleep(1000);
}catch(Exception e){
}
}
while (i<30)
{
System.out.println("HelloWorld");
i = i + 1;
sleep(1000);
}
while (i<30)
{
System.out.println("HelloWorld");
i = i + 1;
sleep(1000);
}
sleep(?) 是毫秒的单位吗?
while (i<30)
{
System.out.println("HelloWorld");
i = i + 1;
sleep(1000);
}
Thread.sleep(1000);
}catch(Exception e){
}
sleep的单位是毫秒
wait主要由于线程同步,一般不用它作延时