关于Java scheduledExecutor

来源:互联网 发布:mac word界面是英文的 编辑:程序博客网 时间:2024/05/16 17:29

Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next. If any execution of the task encounters an exception, subsequent executions are suppressed. Otherwise, the task will only terminate via cancellation or termination of the executor.


以上是官方注释。可见,如果任意一次任务执行出现异常,之后的计划任务将不再执行。


我们可以在任务中加上try catch,以避免某些时候因任务执行出现未预料到的错误而引发的终止。

0 0