java中的模拟设置间隔
我需要检查url(每秒一次) 但我不需要时间表 在JavaScript中,它看起来像java中的模拟设置间隔,java,Java,我需要检查url(每秒一次) 但我不需要时间表 在JavaScript中,它看起来像 var interval = self.setInterval(function(){ console.log(mywindow.location.href); },1000); 我会每秒钟检查一次 您可以使用: timer.scheduleAtFixedRate(yourTimerTask, new Date(), 1000l); 。。。它将计划从现在开始执行,每秒钟一次 请注意,启动时间和速率不
var interval = self.setInterval(function(){
console.log(mywindow.location.href);
},1000);
我会每秒钟检查一次
您可以使用:
timer.scheduleAtFixedRate(yourTimerTask, new Date(), 1000l);
。。。它将计划从现在开始执行,每秒钟一次
请注意,启动时间和速率不能保证按时间精确执行
有关该方法的API文档,请参阅
timer.schedule( task, 0L ,1000L);
timer.scheduleAtFixedRate(yourTimerTask, new Date(), 1000l);