这个是我在程序里用的一个方法
Runnable runnable = new Runnable() {
public void run() {
// task to run goes here
id=id+1;
}
};
ScheduledExecutorService service = Executors
.newSingleThreadScheduledExecutor();
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
service.scheduleAtFixedRate(runnable, 100, 100, TimeUnit.SECONDS);
或者
setInterval() ——每隔一秒自动执行方法,setInterval方法或字符串 ,毫秒,参数数组(方法的))
var c=0;
function showLogin()
{
alert(c++);
}
setInterval("showLogin()","1000");