开发者

How to schedule (and reset) a task programmatically with SpringFramwork?

There is a situation where I want to invoke a method after some predetermined time, say 30 sec or 5 min.

Time needs to be configur开发者_StackOverflow中文版ed at run time, means I should be able to change time dynamically from 5 min to 3 min.(reset the timer to new interval programmatically)

I am developing a dynamic web project using Spring framework.

I have checked the Quartz and Timer classes but they seem to read XML configuration for parameters such as delay, repeatInterval and so on.

How can I do that? Does Spring provide any support for this?

Thank you in advance.


The easiest way is to configure and inject an instance of something that implements Spring's TaskScheduler interface (e.g. ThreadPoolTaskExecutor). This provides various methods to schedule tasks for delayed execution.

Quartz is overkill for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜