当前位置:网站首页>Timer创建定时器
Timer创建定时器
2022-07-06 23:09:00 【洋啊桑815】
import java.util.Timer;
import java.util.TimerTask;
public class TestDamo {
public static void main(String[] args) {
Timer timer=new Timer();//定时器本身就是一个线程
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println(Thread.currentThread()+"执行一次");
}
},3000,2000);
/*
* Timer是单线程,处理多个任务按照顺序执行,存在延时与设置定时器的时间有出入
* 可能会因为其中的某个异常使Timer线程死亡,从而影响后续任务,
* */
}
}
Timer是单线程,处理多个任务按照顺序执行,存在延时与设置定时器的时间有出入
* 可能会因为其中的某个异常使Timer线程死亡,从而影响后续任务,
边栏推荐
- Error: No named parameter with the name ‘foregroundColor‘
- 【二叉树】二叉树寻路
- 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
- HarmonyOS第四次培训
- Ansible overview and module explanation (you just passed today, but yesterday came to your face)
- LabVIEW在打开一个新的引用,提示内存已满
- ThinkPHP关联预载入with
- JS variable case output user name
- Why JSON is used for calls between interfaces, how fastjson is assigned, fastjson 1.2 [email protected] Mapping relatio
- AOSP ~Binder 通信原理 (一) - 概要
猜你喜欢
Ansible概述和模块解释(你刚走过了今天,而扑面而来的却是昨天)
Leetcode(46)——全排列
Basic knowledge of road loss of 3GPP channel model
The sooner you understand the four rules of life, the more blessed you will be
pmp真的有用吗?
Error: No named parameter with the name ‘foregroundColor‘
JS also exports Excel
U++ game learning notes
3GPP信道模型路损基础知识
Ansible报错:“msg“: “Invalid/incorrect password: Permission denied, please try again.“
随机推荐
U++ metadata specifier learning notes
QT控件样式系列(一)之QSlider
Addressable 预下载
Ansible reports an error: "MSG": "invalid/incorrect password: permission denied, please try again“
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
高数中值定理总结
批量归一化(标准化)处理
Meow, come, come: do you really know if, if else
《四》表单
Leetcode(46)——全排列
Weebly mobile website editor mobile browsing New Era
Using thread class and runnable interface to realize the difference between multithreading
[Yugong series] go teaching course 005 variables in July 2022
vector和类拷贝构造函数
window定时计划任务
U++ 元数据说明符 学习笔记
JS 的 try catch finally 中 return 的执行顺序
Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.
Monitoring cannot be started after Oracle modifies the computer name
app内嵌h5---iphone软键盘遮挡输入文字