当前位置:网站首页>Hutool dynamically adds scheduled tasks
Hutool dynamically adds scheduled tasks
2022-07-03 03:33:00 【Today, the flowers are sad】
introduce hutool
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.6.5</version> </dependency>
In the startup class (springboot project ) Add the following code :
// Second level timing tasks are supported
CronUtil.setMatchSecond(true);
// The scheduled service starts
CronUtil.start();
After triggering, the background execution logic
// Start timing task @GetMapping("/start") public String start() { // Dynamically add scheduled tasks , Because the scheduled service has been started when the project is started , So after adding cron Execute when the condition is triggered String jobId = CronUtil.schedule("0/1 * * * * ? ", new Task() { @Override public void execute() { System.out.println(" Scheduled task execution "); } }); if (!StringUtils.isEmpty(jobId)) { return jobId; } else { return null; } } // Stop the corresponding scheduled task @GetMapping("/stop/{jobid}") public void stop(@PathVariable("jobid")String jobid) { CronUtil.remove(jobid); }
边栏推荐
- 基于QT的tensorRT加速的yolov5
- [mathematical logic] propositional logic (propositional logic reasoning | formal structure of reasoning | inference law | additional law | simplification law | hypothetical reasoning | refusal | disju
- ffmpeg录制屏幕和截屏
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- Yolov5 project based on QT
- Applet get user avatar and nickname
- Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
- @The difference between Autowired, @qualifier, @resource
- 【全民编程】《软件编程-讲课视频》【零基础入门到实战应用】
- 基于Qt的yolov5工程
猜你喜欢
softmax的近似之NCE详解
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
Vs Code configure virtual environment
Unity3d RPG implementation (medium)
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
Applet get user avatar and nickname
MongoDB复制集【主从复制】
The calculation of stripe, kernel and padding in CNN
Pat class B "1104 forever" DFS optimization idea
随机推荐
Hi3536c v100r001c02spc040 cross compiler installation
[combinatorics] brief introduction to generating function (definition of generating function | Newton binomial coefficient | commonly used generating function | correlation with constant | correlation
C# WebRequest POST模式 ,基于“Basic Auth”口令认证模式,使用multipart/form-data方式上传文件及提交其他数据
程序员新人上午使用 isXxx 形式定义布尔类型,下午就被劝退?
渤、黄海的潮汐特征
Bigvision code
npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
使用InputFilter限制EditText时踩坑及解决方案
PHP generates PDF tcpdf
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
[mathematical logic] predicate logic (individual word | individual domain | predicate | full name quantifier | existence quantifier | predicate formula | exercise)
FileZilla Client下載安裝
Mongodb replication set [master-slave replication]
Pytorch multi card distributed training distributeddataparallel usage
用Three.js做一个简单的3D场景
Vs 2019 installation and configuration opencv
为什么线程崩溃不会导致 JVM 崩溃
numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
ffmpeg之 一张/多张图片合成视频