当前位置:网站首页>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线程死亡,从而影响后续任务,
边栏推荐
猜你喜欢
Ansible overview and module explanation (you just passed today, but yesterday came to your face)
Meow, come, come: do you really know if, if else
【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
SQL injection HTTP header injection
LabVIEW在打开一个新的引用,提示内存已满
当 Knative 遇见 WebAssembly
qt 简单布局 盒子模型 加弹簧
C语言中函数指针与指针函数
Tree map: tree view - draw covid-19 array diagram
记录一次压测经验总结
随机推荐
y58.第三章 Kubernetes从入门到精通 -- 持续集成与部署(三一)
【Android Kotlin协程】利用CoroutineContext实现网络请求失败后重试逻辑
2.证券投资基金的概述
If you ask me about R code debugging, I will tell you head, STR, help
The execution order of return in JS' try catch finally
带你遨游银河系的 10 种分布式数据库
Salesforce 容器化 ISV 场景下的软件供应链安全落地实践
torch optimizer小解析
App embedded H5 --- iPhone soft keyboard blocks input text
Analysis -- MySQL statement execution process & MySQL architecture
R descriptive statistics and hypothesis testing
ASP. Net MVC - resource cannot be found error - asp Net MVC – Resource Cannot be found error
np.random.shuffle与np.swapaxis或transpose一起时要慎用
装饰器基础学习02
ThinkPHP关联预载入with
Ansible reports an error: "MSG": "invalid/incorrect password: permission denied, please try again“
高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍
QT控件样式系列(一)之QSlider
A row of code r shows the table of Cox regression model
IMS data channel concept of 5g vonr+