Running a Java method at a set time each day

后端 未结 3 1794
不知归路
不知归路 2020-12-30 02:54

I\'m relatively new to Java and I\'ve pick up a project to work on. However, I\'ve run into a block. I need a method to run at a certain times throughout the day. I\'ve d

3条回答
  •  北海茫月
    2020-12-30 03:16

    One possibility could be to use an external scheduler - depending on desired accuracy. On UNIX use CRON, on Windows use the Windows Scheduler. That nicely isolates timing from doing.

    You could use a Timer and create a simple class that checks the time every minute or 5 minutes depending on desired granularity. It would be very lightweight.

提交回复
热议问题