当前位置:网站首页>ScheduledExecutorService定时器
ScheduledExecutorService定时器
2022-07-06 23:09:00 【洋啊桑815】
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class TestDamo {
public static void main(String[] args){
//ScheduledExecutorService 内部为线程池 弥补了Timer的缺陷
ScheduledExecutorService pool = Executors.newScheduledThreadPool(3);
pool.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
System.out.println(Thread.currentThread()+"执行一次");
}
},0,2, TimeUnit.SECONDS);
}
}
ScheduledExecutorService 内部为线程池 弥补了Timer的缺陷
边栏推荐
- JS input and output
- window定时计划任务
- Mysql database (basic)
- Basic knowledge of road loss of 3GPP channel model
- Common Oracle SQL statements
- 【opencv】图像形态学操作-opencv标记不同连通域的位置
- Servicemesh mainly solves three pain points
- 3GPP信道模型路损基础知识
- Stm32f103ze+sht30 detection of ambient temperature and humidity (IIC simulation sequence)
- Meow, come, come: do you really know if, if else
猜你喜欢
随机推荐
Two methods of chromosome coordinate sequencing
史上最全学习率调整策略lr_scheduler
当 Knative 遇见 WebAssembly
No experts! Growth secrets for junior and intermediate programmers and "quasi programmers" who are still practicing in Universities
PLC模拟量输出 模拟量输出FB analog2NDA(三菱FX3U)
The sooner you understand the four rules of life, the more blessed you will be
《四》表单
精彩速递|腾讯云数据库6月刊
Mysql database (basic)
Appium practice | make the test faster, more stable and more reliable (I): slice test
[736. LISP syntax parsing]
Why JSON is used for calls between interfaces, how fastjson is assigned, fastjson 1.2 [email protected] Mapping relatio
DBSync新增对MongoDB、ES的支持
Markdown editor
A simple and beautiful regression table is produced in one line of code~
Why is the salary of test and development so high?
一文搞懂常见的网络I/O模型
批量归一化(标准化)处理
Salesforce 容器化 ISV 场景下的软件供应链安全落地实践
Function pointer and pointer function in C language