当前位置:网站首页>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 !~
边栏推荐
- 知乎上的那些神回复
- PCI express physical layer - electrical part
- Getaverse, a distant bridge to Web3
- The assignment and answer of the "Cyberspace Security" competition of the 2020 secondary vocational group in Zhejiang Province (flag)
- C Programming classic tutorial
- 永恒之蓝MS17-010exp复现
- 【历史上的今天】7 月 24 日:Caldera 诉微软案;AMD 宣布收购 ATI;谷歌推出 Chromecast
- Hangdian multi School Game 1 question 3 backpack (XOR dp+bitset)
- Common problems of multithreading and concurrent programming (to be continued)
- MySQL optimization series (2) -- InnoDB important parameter optimization
猜你喜欢

matplotlib

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

Nftscan and port3 have reached strategic cooperation in the field of NFT data

Leetcode memory deep search / dynamic planning V2

C Programming classic tutorial

National vocational college skills competition network security competition -- detailed explanation of Apache security configuration

Crazy God redis notes 11

理解动态计算图,requires_grad、zero_grad

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

Typora user manual
随机推荐
Solve the problem of disconnection due to long idle time after SSH login
vim相关介绍
【TkInter】布局管理和事件系统
About core files
04-分布式资源管理系统YARN
Ionic4 learning notes 9 -- an east project 01
Redis data type
Ionic4 learning notes 7 -- UI component 1 (no practice, direct excerpt)
Introduction to VIM
OpenGL learning (V) modern OpenGL triangle rendering
Principle and application of database
[Tkinter] common components (II)
Why is gradient the fastest changing direction of function
Converter
EasyUI adds row level buttons to the DataGrid
FPGA 20个例程篇:9.DDR3内存颗粒初始化写入并通过RS232读取(上)
[wechat applet development] custom tabbar case (custom message 99 + little hearts)
2022 Hangdian multi school second session 1009 shuangq (Mathematics)
04 distributed resource management system yarn
Nftscan and port3 have reached strategic cooperation in the field of NFT data