The meaning of schedule (timetable, schedule)
Timer.schedule (New TimerTask () {void run ()},0, 60*60*1000);
Timer.schedule (New MyTask (Event.getservletcontext ()), 0, 60*60*1000);
First parameter "New MyTask (Event.getservletcontext ())":
is the TimerTask class, in the package: import Java.util.TimerTask. The consumer inherits the class and implements the public void run () method, because the TimerTask class implements the Runnable interface.
The second parameter "0" means: (0 means no delay)
When you call this method, the method is bound to call the run () method in the TimerTask class TimerTask class, which is the difference between the time between the two, that is, after the user calls the schedule () method, it takes such a long time to execute the run () party for the first time. Method.
The third parameter, "60*60*1000", means:
(Unit is in milliseconds 60*60*1000 for one hour)
(in milliseconds 3*60*1000 to three minutes)
After the first call, the run () method is called once every number of times from the second start.
Https://www.cnblogs.com/lcngu/p/5010377.html
Add:
Is there a problem with schedule multiple tasks with the same timer?
A Timer object in Java itself has only one thread, and if multiple tasks are submitted to him, and a task is time-consuming, the other task will still wait until the execution is complete, even when the task is executed. More problematic, if the previous task throws an exception that causes the thread to terminate, the subsequent task cannot execute.
Java5 recommend the use of Java.util.concurrent scheduledexecutorservice, at least to avoid the problem that causes the thread to end.
If you need more accurate time, be sure to handle a task with a scheduledexecutorservice.
Another said that daily scheduled tasks, with the Windows Task plan, Linux Crond execute a Java application can be implemented, why use the Java timer to keep the process resident, the longer the operation.
Java Timer, TimerTask, Timer.schedule