Common thread implementation
Hours 和 Hours Task
JDK comes java.util.Timer
; scheduling by java.util.TimerTask
way let the program, but can not run at a certain time in accordance with the frequency of execution. Usually less used.
ScheduledExecutorService方式
ScheduledExecutorService from Java SE java.util.concurrent 5's, as concurrency tools are introduced, this is the ideal way to achieve the scheduled task.
And Timer
is very similar, but it's better when multi-threaded parallel processing timing tasks, Timer
run more TimeTask
time, as long as there is a task due to an error not caught the thrown exception, other tasks will automatically terminate the run, you can use ScheduledExecutorService to circumvent this problem
Friday fast work, and happy weekend oh