xxl-job 里定时任务触发实现疑问

讨论 未结 1 39
rqxiao
rqxiao 会员 2022年9月29日 10:19 发表
<p>今天在想 java 中的定时任务的功能是怎么实现的?</p> <p>先看了 ScheduledExecutorService ,里面的实现简单的理解是 DelayQueue 死循环调用 Condition 类的 await(),等待时间结束后,return q.poll(,完成了延时的定时执行? <a href="https://imgse.com/i/xnBxnf" rel="nofollow"><img alt="xnBxnf.jpg" class="embedded_image" loading="lazy" referrerpolicy="no-referrer" rel="noreferrer" src="https://s1.ax1x.com/2022/09/29/xnBxnf.jpg"></a></p> <p>又想看下之前工作中了解过的 xxl-job 是怎么完成的,源码看不懂,这篇文章解释了一下,<a href="https://zhuanlan.zhihu.com/p/356696236" rel="nofollow">https://zhuanlan.zhihu.com/p/356696236</a> 可以理解为死循环中有个线程不断的再查数据库的 xxl-job 中 5 秒内需要执行的任务,然后判断,定时任务一般是这么实现的吗 <a href="https://imgse.com/i/xnDEj0" rel="nofollow"><img alt="xnDEj0.md.jpg" class="embedded_image" loading="lazy" referrerpolicy="no-referrer" rel="noreferrer" src="https://s1.ax1x.com/2022/09/29/xnDEj0.md.jpg"></a></p>
收藏(0)  分享
相关标签: 灌水交流
注意:本文归作者所有,未经作者允许,不得转载
1个回复
  • wolfie
    2022年9月29日 10:19
    xxl-job 跟 DelayQueue 有啥联系吗? 通过 SQL:from xxl_job_info where trigger_status = 1 and trigger_next_time <= #{maxNextTime} 轮训找任务并分发出去,计算下一次执行时间就完事了。
    0 0