public static void main(String[] args) {
// 创建任务队列
ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(10); // 10 为线程数量
// 执行任务
scheduledExecutorService.scheduleAtFixedRate(() -> {
System.out.println("Run Scheduled:" + new Date());
}, 1, 3, TimeUnit.SECONDS); // 1s 后开始执行,每 3s 执行一次
}
04-07
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-08
525
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-18
1444
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交