java.util.Timer.schedule如何避免启动时指定时间过了就立刻执行一次?
ringa_lee
ringa_lee 2017-04-18 09:58:53
0
2
781

schedule的开始时间设置的是一个固定时间,比如中午12点,如果过了12点启动,那么会立刻执行一次,有没有办法能过了任务的指定开始时间就不执行了等下一次?

ringa_lee
ringa_lee

ringa_lee

reply all (2)
左手右手慢动作
public void schedule(TimerTask task, long delay, long period)

Isn’t it possible to use this interface? Calculate the number of milliseconds from the current time to 12 noondelayperiod是今天中午12点至明天中午12点就是24小时的毫秒数。这样如果当前时间超过12点了。那delayand it will be the next 12 o'clock.

    巴扎黑

    Can you add a method to judge whether the current time is not equal to the scheduled time and not start it? I have never done this...

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!