java调度器 quartz

几个关键对象:

Scheduler - the main API for interacting with the scheduler.
Job - an interface to be implemented by components that you wish to have executed by the scheduler.
JobDetail - used to define instances of Jobs.
Trigger - a component that defines the schedule upon which a given Job will be executed.
JobBuilder - used to define/build JobDetail instances, which define instances of Jobs.
TriggerBuilder - used to define/build Trigger instances.

在网上看到很多jobdetail class,自己下的2.2版本的是interface。
另外job类一定要是public否则会报错,因为内部会通过反射区newinstance个对象
job类不能是内部类,
setRepeatCount 如果不设定,job会默认执行一次,另外设定为-1为无限次

如果计划的时间比较复杂可以用crontrigger,里面的表达式和shell差不多。

你可能感兴趣的:(quartz)