public class SensorStartQuartz implements Runnable {
@ Override
Public void the run () {
Try {
JobDetail JobDetail=JobBuilder. NewJob (StartClientSensorJob. Class). WithIdentity (" job1 is ", "group1"). The build ();
Trigger the Trigger.=TriggerBuilder newTrigger (.) withIdentity (" trigger1 ", "group1")
WithSchedule (SimpleScheduleBuilder. SimpleSchedule (.) withIntervalInSeconds (2) repeatForever ())
.build();
//create the scheduler
SchedulerFactory SchedulerFactory=new StdSchedulerFactory ();
The Scheduler Scheduler=schedulerFactory. GetScheduler ();
//the task and the trigger in the scheduler
The scheduler. ScheduleJob (jobDetail, trigger);
} the catch (Exception e) {
e.printStackTrace();
}
}
Public static void main (String [] args) throws SchedulerException, InterruptedException {
JobDetail JobDetail=JobBuilder. NewJob (StartClientSensorJob. Class). WithIdentity (" job1 is ", "group1"). The build ();
Trigger the Trigger.=TriggerBuilder newTrigger (.) withIdentity (" trigger1 ", "group1")
WithSchedule (SimpleScheduleBuilder. SimpleSchedule (.) withIntervalInSeconds (2) repeatForever ())
.build();
//create the scheduler
.//Scheduler Scheduler=StdSchedulerFactory getDefaultScheduler ();
SchedulerFactory SchedulerFactory=new StdSchedulerFactory ();
The Scheduler Scheduler=schedulerFactory. GetScheduler ();
//the task and the trigger in the scheduler
The scheduler. ScheduleJob (jobDetail, trigger);
The scheduler. The start ();
}
}
New to this, written by an example, this code implements the main single, the scheduler. Begin each 2 seconds after the start () performs a StartClientSensorJob. Class;; But if the thread from other classes, implement the run method, execute to the scheduler. The scheduleJob (jobDetail, trigger) did not start () method begins to run after StartClientSensorJob. Class, what's going on, Meng,
CodePudding user response:
May be set to it just start to perform a first, and then the implementation is you set the time, quartz. The properties configuration file. Try to join the misfireInstruction=CronTrigger MISFIRE_INSTRUCTION_DO_NOTHING