当前位置:网站首页>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的缺陷
边栏推荐
- 第一篇论文的写作流程
- Clickhouse (03) how to install and deploy Clickhouse
- 高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍
- 为什么很多人对技术债务产生误解
- U++ 元数据说明符 学习笔记
- offer如何选择该考虑哪些因素
- A line of R code draws the population pyramid
- Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
- Using thread class and runnable interface to realize the difference between multithreading
- 谈谈讲清楚这件事的重要性
猜你喜欢
CentOS 7.9安装Oracle 21c历险记
The sooner you understand the four rules of life, the more blessed you will be
Markdown编辑器
Batch normalization (Standardization) processing
Ansible报错:“msg“: “Invalid/incorrect password: Permission denied, please try again.“
《五》表格
window定时计划任务
U++ 游戏类 学习笔记
LabVIEW在打开一个新的引用,提示内存已满
JS variable plus
随机推荐
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
Mysql database (basic)
谈谈讲清楚这件事的重要性
Analyse approfondie de kubebuilder
The execution order of return in JS' try catch finally
Tree map: tree view - draw covid-19 array diagram
Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
一个酷酷的“幽灵”控制台工具
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
【二叉树】二叉树寻路
[Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
批量归一化(标准化)处理
【736. Lisp 语法解析】
np.random.shuffle与np.swapaxis或transpose一起时要慎用
If you‘re running pod install manually, make sure flutter pub get is executed first.
《二》标签
3.基金的类型
Factor analysis r practice (with R installation tutorial and code)
Leetcode minimum difference in student scores
[Yugong series] go teaching course 005 variables in July 2022