Java regular tasks summary

Common thread implementation

 Hours 和 Hours Task

  JDK comes java.util.Timer; scheduling by java.util.TimerTaskway 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 Timeris very similar, but it's better when multi-threaded parallel processing timing tasks, Timerrun more TimeTasktime, 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

Guess you like

Origin www.cnblogs.com/woxbwo/p/11289865.html