java中的模拟setinterval

mr_*_*ody 3 java

我需要检查网址(每秒一次)

Timer timer = new Timer();
    TimerTask task = new TimerTask() {
        public void run()
        {
            System.out.print(engine.getLocation());
        }
    };
timer.schedule( task, 1000 );
Run Code Online (Sandbox Code Playgroud)

但我不需要时间表

在JavaScript中它看起来像

var interval = self.setInterval(function(){
    console.log(mywindow.location.href);
},1000);
Run Code Online (Sandbox Code Playgroud)