当前位置:网站首页>任务调度线程池-应用定时任务
任务调度线程池-应用定时任务
2022-08-01 20:22:00 【Q z1997】
任务调度线程池-应用定时任务
示例每周四18:00:00 执行
// 获得当前时间
LocalDateTime now = LocalDateTime.now();
// 获取本周四 18:00:00.000
LocalDateTime thursday =
now.with(DayOfWeek.THURSDAY).withHour(18).withMinute(0).withSecond(0).withNano(0);
// 如果当前时间已经超过 本周四 18:00:00.000, 那么找下周四 18:00:00.000
if (now.compareTo(thursday) >= 0) {
thursday = thursday.plusWeeks(1);
}
// 计算时间差,即延时执行时间
long initialDelay = Duration.between(now, thursday).toMillis();
// 计算间隔时间,即 1 周的毫秒值
long oneWeek = 7 * 24 * 3600 * 1000;
ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
System.out.println("开始时间:" + new Date());
executor.scheduleAtFixedRate(() -> {
System.out.println("执行时间:" + new Date());
}, initialDelay, oneWeek, TimeUnit.MILLISECONDS);
边栏推荐
- LabVIEW 使用VISA Close真的关闭COM口了吗
- 解除360对默认浏览器的检测与修改
- 【节能学院】智能操控装置在高压开关柜的应用
- PROE/Croe如何编辑已完成的草图,让其再次进入草绘状态
- 我的驾照考试笔记(3)
- 大整数相加,相减,相乘,大整数与普通整数的相乘,相除
- latex paper artifact -- server deployment overleaf
- 【torch】张量乘法:matmul,einsum
- 数据可视化
- 57: Chapter 5: Develop admin management services: 10: Develop [get files from MongoDB's GridFS, interface]; (from GridFS, get the SOP of files) (Do not use MongoDB's service, you can exclude its autom
猜你喜欢
![[Energy Conservation Institute] Application of Intelligent Control Device in High Voltage Switchgear](/img/6d/05233ce5c91a612b6247ea07d7982e.jpg)
[Energy Conservation Institute] Application of Intelligent Control Device in High Voltage Switchgear

Application of Acrel-5010 online monitoring system for key energy consumption unit energy consumption in Hunan Sanli Group

Creo5.0 rough hexagon is how to draw

使用Huggingface在矩池云快速加载预训练模型和数据集

【多任务模型】Progressive Layered Extraction: A Novel Multi-Task Learning Model for Personalized(RecSys‘20)

How PROE/Croe edits a completed sketch and brings it back to sketching state
![[Multi-task optimization] DWA, DTP, Gradnorm (CVPR 2019, ECCV 2018, ICML 2018)](/img/a1/ec038eeb6c98c871eb31d92569533d.png)
[Multi-task optimization] DWA, DTP, Gradnorm (CVPR 2019, ECCV 2018, ICML 2018)

MongoDB快速上手

Does LabVIEW really close the COM port using VISA Close?

我的驾照考试笔记(4)
随机推荐
泰德制药董事长郑翔玲荣膺“2022卓越影响力企业家奖” 泰德制药荣获“企业社会责任典范奖”
58:第五章:开发admin管理服务:11:开发【管理员人脸登录,接口】;(未实测)(使用了阿里AI人脸识别)(演示了,使用RestTemplate实现接口调用接口;)
Software you should know as a programmer
模板特例化和常用用法
Creo5.0草绘如何绘制正六边形
Redis does check-in statistics
WhatsApp group sending actual combat sharing - WhatsApp Business API account
卷积神经网络(CNN)mnist数字识别-Tensorflow
Failed to re-init queues : Illegal queue capacity setting (abs-capacity=0.6) > (abs-maximum-capacity
【ES】ES2021 我学不动了,这次只学 3 个。
Use WeChat official account to send information to designated WeChat users
环境变量,进程地址空间
[Personal Work] Remember - Serial Logging Tool
"Torch" tensor multiplication: matmul, einsum
有序双向链表的实现。
使用微信公众号给指定微信用户发送信息
Failed to re-init queues : Illegal queue capacity setting (abs-capacity=0.6) > (abs-maximum-capacity
【节能学院】推进农业水价综合改革的意见解读
【个人作品】无线网络图传模块
给定中序遍历和另外一种遍历方法确定一棵二叉树