任务调度框架总结

在这里插入图片描述

JDK

在这里插入图片描述
JDK代码实践:https://blog.csdn.net/haoranhaoshi/article/details/102897849
JavaFX代码实践:https://blog.csdn.net/haoranhaoshi/article/details/105120277

Spring

在这里插入图片描述
代码实践(源码见:ScheduledAnnotationBeanPostProcessor):

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;

@Configuration
public class ScheduleConfig implements SchedulingConfigurer {

    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(100));
    }

}
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @author zhanghao
 */
@SpringBootApplication
@EnableScheduling
public class ScheduledApplication {

    public static void main(String[] args) {
        // https://blog.csdn.net/weixin_40318210/article/details/78149692
        SpringApplication.run(ScheduledApplication.class, args);
    }

}
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author zhanghao
 */
@Component
public class TestJob {
    @Scheduled(initialDelay = 1000, fixedRate = 1000 * 10)   //1秒后执行,每10秒执行一次
    // ScheduledAnnotationBeanPostProcessor
    public void Task1() throws InterruptedException {
        System.out.println("task1 任务开始, 线程执行ID:" + Thread.currentThread().getId() + "线程名称:" + Thread.currentThread().getName());
        TimeUnit.SECONDS.sleep(10);
        System.out.println("task1 任务结束, 线程执行ID:" + Thread.currentThread().getId() + "线程名称:" + Thread.currentThread().getName());
    }

    @Scheduled(initialDelay = 1000, fixedRate = 1000 * 5)   //每5秒执行一次
    public void Task2() throws InterruptedException {
        System.out.println("task2 任务开始, 线程执行ID:" + Thread.currentThread().getId() + "线程名称:" + Thread.currentThread().getName());
        TimeUnit.SECONDS.sleep(10);
        System.out.println("task2 任务结束, 线程执行ID:" + Thread.currentThread().getId() + "线程名称:" + Thread.currentThread().getName());
    }
}

Quartz

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
quartz代码实践(源码见:QuartzSchedulerThread):https://blog.csdn.net/haoranhaoshi/article/details/102897849

XXL-Job

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Elastic-Job

在这里插入图片描述
在这里插入图片描述

SchedulerX

在这里插入图片描述
DTS:https://blog.csdn.net/yunqiinsight/article/details/90711911
工作流设置:https://help.aliyun.com/document_detail/148205.html?spm=a2c4g.11186623.6.591.1f9547d6JjQaIQ

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风铃峰顶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值