Instancing a new thread in Spring to execute tasks periodically
I have a dashboard made with Spring that must control some task executions. The basic idea is to have a thread to send this tasks periodically to remote trackers. How can I instance this thread? I've been reading a little and some people say that is not a good idea to use thread. Would this cause a problem with Spring life cycle? Is there another way to have a method called periodically?
Spring has support for Task Scheduling. Find more information here:
E.g. you can configure scheduled task in your application context like so:
<task:scheduled-tasks scheduler="myScheduler"> <task:scheduled ref="beanA" method="methodA" fixed-delay="5000"/> </task:scheduled-tasks> <task:scheduler id="myScheduler" pool-size="10"/>