Reputation: 194
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);
Upvotes: 5
Views: 9365
Reputation: 48434
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.
Upvotes: 4