2 u013140391 u013140391 于 2017.09.12 19:11 提问

Thread.sleep问题求解

用的quartz定时任务

代码:
log.info("afternoon task start...");
long delay = random.nextInt(3600) * 1000;
log.info("sleep " + delay + " ms");
Thread.sleep(delay);
log.info("afternoon send start...");

日志:
[INFO ] 2017-09-12 18:00:00,456 16896832 DefaultQuartzScheduler_Worker-1 core.AfternoonJob core.AfternoonJob.send(AfternoonJob.java:20) afternoon task start...
[INFO ] 2017-09-12 18:00:00,457 16896833 DefaultQuartzScheduler_Worker-1 core.AfternoonJob core.AfternoonJob.send(AfternoonJob.java:23) sleep 2655000 ms

然后就没有然后了,按理来说18:44应该要执行的

1个回答

bingyan_wxl
bingyan_wxl   2017.09.13 10:32

会不会是中间停服务了,不过这样写有什么意义吗?想要18:44执行直接用cron表达式指定时间不就行了吗

Csdn user default icon
上传中...
上传图片
插入图片