当前位置:网站首页>Timed task framework
Timed task framework
2022-07-24 18:57:00 【thoughtCodes】
Timing task framework
Survive by day and develop by night.
talk for import biz , show your perfect code,full busy,skip hardness,make a better result,wait for change,challenge Survive.
happy for hardess to solve denpendies.
Catalog

summary
The framework of timed tasks is also a very common requirement .
demand :
1. Timer selection
Design thinking
The simplest timers are :
Use cron Expression processing
Analysis of implementation ideas
1.corn expression
This is the most common use , It's me, too 14 Annual contact cosp When , Accomplished .
second minute Hours Japan month
week year
Mainly corn Use of expressions
2. Database style timer
The expression of database timer is encapsulated inside , 了
quartzs
adopt job To complete the timer setting , Also in 2015 Encountered in .
Defining triggers Trigger And with job binding
@Scheduled Annotation is the simplest way , Just enable the timer , Just add comments on the method .
stay spring Add... To the configuration :
1
2
3
4
5
6
7
8
<task:annotation-driven />
Add notes to the specific methods to be used @Scheduled
@Scheduled(cron = "0 0 * * * ? ")
public void myTask(){
// Timing task …
}
timer scher:
Use Timer Of schedule,schedule Yes 3 Parameters :
schedule(TimerTask task, long delay, long period)
The first is a scheduled task , Rewrite according to business needs TimerTask Of run The method can ;
The second is delayed start , Unit millisecond ;
How often does the third bit run , Unit millisecond ;
Using threads :
Using threads to control is more flexible , You can judge when to run according to your own needs , When to stop , It needs to be right java Have a certain understanding of threads .
Expand to achieve
Reference here :github: Simply implement the above process :
Entry level implementation :
: Partial source code implementation .
: The source code to achieve
Performance parameter test :
nothing
References and recommended readings
Welcome to , Dear brother , If it helps you , A little praise and a little attention !~
边栏推荐
- OpenGL learning (III) glut two-dimensional image rendering
- Principle and application of database
- MySQL -- implicit conversion of data type
- Sqoop
- 【TkInter】布局管理和事件系统
- 网络安全80端口—-PHP CGI参数注入执行漏洞
- Inoic4 learning notes 2
- Hangdian multi School Game 1 question 3 backpack (XOR dp+bitset)
- matplotlib
- Today's sleep quality record 79 points
猜你喜欢

Convolutional Neural Networks in TensorFlow quizs on Coursera

Common problems of multithreading and concurrent programming (to be continued)

OpenGL learning (III) glut two-dimensional image rendering

2022杭电多校第二场1009 ShuanQ(数学)

Ionic4 learning notes 5-- custom public module

MySQL1

Sqoop

FPGA 20 routines: 9. DDR3 memory particle initialization write and read through RS232 (Part 1)

Reading notes of XXL job source code

Easily learn pytoch transfer learning to realize surface defect inspection
随机推荐
Leetcode memory deep search / dynamic planning V2
On dynamic application of binary array
Ionic4 learning notes 7 -- UI component 1 (no practice, direct excerpt)
字符串的遍历及拼接
Serial vector format (SVF) file format
Ionic4 learning notes 9 -- an east project 01
leetcode-记忆化深搜/动态规划v2
32-bit stack overflow advanced
Make C #
Eternal Blue ms17-010exp reappears
The difference between static method and instance method
使用der格式公钥生成publicKey报错
epoch,batch_ size
Analysis of several possible causes of 0xc0000005 memory violation
JVM method call
【Tkinter】常用组件(二)
Add column by column selection for JTable
vim相关介绍
OPENGL学习(三)GLUT二维图像绘制
PCIe link initialization & Training