<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>定时任务 on Shellj的博客</title>
    <link>https://im.shellj.com/tags/%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1/</link>
    <description>Recent content in 定时任务 on Shellj的博客</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 22 Dec 2023 01:58:35 +0800</lastBuildDate>
    <atom:link href="https://im.shellj.com/tags/%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Spring Scheduled 三种定时方式</title>
      <link>https://im.shellj.com/posts/2022/11/spring-scheduled/</link>
      <pubDate>Mon, 14 Nov 2022 22:09:00 +0800</pubDate>
      <guid>https://im.shellj.com/posts/2022/11/spring-scheduled/</guid>
      <description>&lt;p&gt;前面出了&lt;a href=&#34;https://im.shellj.com/2022/11/a-20000-bug.html&#34;&gt;一个20000+元的 Bug&lt;/a&gt;，现在来认真的看看 Spring Schedule 是如何处理定时任务的。&lt;/p&gt;&#xA;&lt;h2 id=&#34;spring-schedule-配置时间的三种方式&#34;&gt;Spring Schedule 配置时间的三种方式&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;fixRate: 间隔时间，会根据首次执行时间预先安排固定的时间，错过立即执行&lt;/li&gt;&#xA;&lt;li&gt;fixDelay: 间隔时间，上次结束时间后多少间隔后执行&lt;/li&gt;&#xA;&lt;li&gt;cron: 指定具体时间，错过立即执行&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;fixrate-运行方式&#34;&gt;fixRate 运行方式&lt;/h2&gt;&#xA;&lt;p&gt;fixRate 是会根据开始时间预先安排一系列的固定时间点，如果错过了安排的时间点，则立即执行，否则等待下一个执行时间点，如下图 fixRate=5000，每5秒执行一次，第二次执行超过了预先安排的点，导致第三次错过，则第三次立即执行，二第四次则在正常安排的时间点执行，值得注意的是第三次与第四次相隔仅一秒。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
