When you do a timed task, you can use spring's own timing task framework.
Use Scheduled-tasks Example:
Add the following code to the spring configuration file:
<task:scheduled-tasks scheduler= "Myscheduler" > <task:scheduled ref= "Beana" method= "
MethodA" fixed-delay= "5000" initial-delay= "1000"/> <task:scheduled ref= "beanb"
method= "MethodB" fixed-rate= "5000" />
<task:scheduled ref= "Beanc" method= "methodc" cron= "*/5 * * * mon-fri"/> </task
: scheduled-tasks>
<task:scheduler id= "Myscheduler" pool-size= "ten"/>
A task namespace needs to be introduced;
For example: xmlns:task= "Http://www.springframework.org/schema/task"
xsi:schemalocation= "Http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
Spring timing Framework See more: http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/# Scheduling-annotation-support