try {
Thread.currentThread().sleep(5 * 1000);
}
catch(InterruptedException e) {}
}
将以上代码加入希望延时的地方sleep()的参数是毫秒值
上面代码的作用是暂停5秒钟
Thread.currentThread().sleep(5 * 1000);
}
catch(InterruptedException e) {}
}
将以上代码加入希望延时的地方sleep()的参数是毫秒值
上面代码的作用是暂停5秒钟
这是一个意思啊
5*1000意思是告诉看程序的,这是5秒……
<@_@>
1)try {
Thread.currentThread().sleep(5 * 1000);
}
catch(InterruptedException e) {}
}
将以上代码加入希望延时的地方sleep()的参数是毫秒值
上面代码的作用是暂停5秒钟(不好意思盗版了,向alphazhao表示道歉)2)Timer time1,time2;
time1=new Timer(1000,this);
time2=new Timer(2000,boy);//boy对象作计时器的监视器
time1.start();time2.start();
public void actionPerformed(ActionEvent e)
{text1.append("欢迎光临"+"\n") ;
}
}
class Boy implements ActionListener
{ public void actionPerformed(ActionEvent e)
{TimeWin.text2 .append("欢迎光临"+"\n") ;
}
}试试看,GOOK LUCK!
注意wait()/notify()都需要放在synchronized程序体中。
Thread.sleep(1000);
}catch(InterruptedException e){
System.out.println(e.toString());
}
//*可以使程序等待1秒,直接粘贴到你的程序中即可*/另:
import java.io.IOException;
//以下代码写在main函数里
System.out.println("press enter to exit");
try {
System.out.read();//read some input from the keyboaed
}catch(IOException e){ //catch the input exception
return; //and just return
}//*等待回车键,才退出*/
一个n小的问题,有必要搞得如此复杂么?