定时任务ThreadPoolTaskScheduler


package com.doudou.task;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;

public class BackgroundTask {

ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();

public void start(){

    if(scheduler != null){
        scheduler.initialize();
    }

    scheduler.schedule(new TaskRunable(), new CronTrigger("0/5 * * * * ?"));
}

public void stop(){
    if(scheduler != null){
        scheduler.shutdown();
    }
}

}

你可能感兴趣的:(java,定时任务)