I'm developing an web application which is developed in Struts 2 and I'm deploying it on Apache Tomcat server.
I want to do database cleanup on daily basis automatically.
Also I want to to call a method in java class with 10 minutes of interval. Any suggestion for this.
You can use Quartz scheduler with Struts2 or Spring's @Scheduled
. Here's the example to use Struts 2 + Spring 3 + Quartz 1.8 Scheduler Example .
There you can modify cron expression to run every 10 min
<property name="cronExpression" value="* 0/10 * * * ?" />
ScheduledExecutorService
This topic has been addressed many times already on a Stack Overflow.
Specifically look at ScheduledExecutorService
.
A background thread can run your task at regular intervals.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.