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 configured 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With