@Scheduled行为在处理时间较长时会并行运行吗?

huangapple go评论83阅读模式
英文:

@Scheduled behaviour when processing takes a long time. run in parallel?

问题

如果该方法处理时间超过10秒,是否会同时启动另一个执行?还是会等待当前执行完成?

英文:

I have a method with @Scheduled and this is set to run every 10 secs like so:

@Scheduled(fixedDelay = 1000 * 10)

If the method takes more than 10 secs to process, will another execution start in parallel? or will it wait for the current execution to finish?

答案1

得分: 1

It won't, because fixedDelay works like follows:

Execute the annotated method with a fixed period in milliseconds
between the end of the last invocation and the start of the next.

意味着它等待函数完成,然后等待 n 毫秒,然后再次调用函数。

英文:

It won't, because fixedDelay works like follows:

> Execute the annotated method with a fixed period in milliseconds
> between the end of the last invocation and the start of the next.

Meaning that it waits for the function to complete and then waits n-milliseconds until the function is invoked again.

答案2

得分: 1

以下是翻译好的部分:

"它将等待前一个执行完成,我正在查看它的文档,上面写着

以毫秒为单位的固定周期执行带有注释的方法,上一次调用结束和下一次调用开始之间的间隔。

这里是Spring文档,我在那里看到它。"

英文:

It will wait until previous execution is completed I was going through its doc and its written over there

> Execute the annotated method with a fixed period in milliseconds
> between the end of the last invocation and the start of the next.

Here is the Spring Doc where I have seen it.

huangapple
  • 本文由 发表于 2020年8月13日 15:53:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63390549.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定