赞
踩
任务Task(Job)
JobDetail及 Job 类
JobDetail: 任务数据
Job: 任务逻辑
JobExecutionContext: Job运行时上下文信息
public class PrintWordsJob implements Job {
}
JobDetail jobDetail = JobBuilder.newJob(PrintWordsJob.class)
.withIdentity("job1", "group1").build();
触发器Trigger
Trigger:
SimpleTrigger: 简单触发器
CronTrigger: 基于日历的作业调度
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "triggerGroup1")
.startNow()//立即生效
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(1)//每隔1s执行一次
.repeatForever()).build();//一直执行
scheduler.scheduleJob(jobDetail, trigger);
调度器Scheduler
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。