SimpleTrigger

package  hvp.spring.quartz.simpleTrigger;

import  java.util.Date;

import  org.quartz.JobDetail;
import  org.quartz.Scheduler;
import  org.quartz.SchedulerException;
import  org.quartz.SchedulerFactory;
import  org.quartz.SimpleTrigger;
import  org.quartz.impl.StdSchedulerFactory;

public   class  SimpleTriggerRunner
{
    
public void test() throws SchedulerException
    
{
        
// 建立JobDetail
        JobDetail jobDetail = new JobDetail("job1_1""jGroup1",
                SimpleJob.
class);
        
// 建立触发器
        SimpleTrigger simpleTrigger = new SimpleTrigger("job1_1""jGroup1");
        simpleTrigger.setStartTime(
new Date());
        simpleTrigger.setRepeatInterval(
2000);
        simpleTrigger.setRepeatCount(
100);
        
        
// 生成高度器
        SchedulerFactory schedulerFactory = new StdSchedulerFactory();
        Scheduler scheduler 
= schedulerFactory.getScheduler();
        
        
// 关联任务和触发器
        scheduler.scheduleJob(jobDetail, simpleTrigger);
        
// 开始调度
        scheduler.start();
    }

    
    
public static void main(String[] args)
    
{
        
try
        
{
            SimpleTriggerRunner str 
= new SimpleTriggerRunner();
            str.test();
        }

        
catch (Exception e)
        
{}
    }

}

你可能感兴趣的:(spring,quartz)