Spring Java - Running process performs tasks once a day

java, scheduled-tasks, spring, spring-mvc

Solution

You could also use the @Scheduled Annotation akin to:

@Scheduled(cron="0 0 * * *")
public void doStuff() {
   ..
}

Check the decumentation here: there are a lot of different methods to do it.

Problem

I have a little problem (I am using spring version 3.1.1). I want to start a process or thread that performs a task in one day. So for example: I have a list of users and every user has a total count of days as field. class User{ String ... String ... DateTime countDays = ...12-12-12... } So what I want to do is, when i start my application (running), I want to perform a task everyday: Loop through the list of users Check the countDays If countDays is greater then 14 for example Send something to the user.... I do know how to loop through and send something. I dont know how I can start an object en let it perform one task in a day. Create a bean, construct it and use sleep function???? Hope somebody can help me out, I thank you! :D

Original source