How i can run my TimerTask everyday 2 PM

后端 未结 9 1674
说谎
说谎 2020-12-01 02:48

I want to execute a job everyday 2PM . Which method of java.util.Timer i can use to schedule my job?

After 2Hrs Run it will stop the job and reschedule

9条回答
  •  独厮守ぢ
    2020-12-01 03:29

    You should try using scheduleAtFixedRate (this will repeat your task). You will need to create an TimerTask object which will specify what to run (in run()) and when to run (scheduledExecutionTime). scheduleAtFixedRate also allows you to specify the first date of execution.

提交回复
热议问题