I need to check the url (once per second)
Timer timer = new Timer();
TimerTask task = new TimerTask() {
public void run()
{
System.out.print(engine.getLocation());
}
};
timer.schedule( task, 1000 );
but I don't need schedule
In JavaScript it would look like
var interval = self.setInterval(function(){
console.log(mywindow.location.href);
},1000);
timer.schedule( task, 0L ,1000L);
will check every second.
http://docs.oracle.com/javase/6/docs/api/java/util/Timer.html#schedule(java.util.TimerTask,%20long,%20long)
You can use:
timer.scheduleAtFixedRate(yourTimerTask, new Date(), 1000l);
... which will schedule execution starting now, each second.
Note that the start time and rate are not guaranteed to execute precisely time-wise.
See here for API documentation on the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With