I need to write a Java class, which fetches different times from a database and then calls a function at those times. The times can change in the database and a value corresponding to the time in the Db is sent as arguments to the function. I need to make sure this happens everyday at the time mentioned in the Db.
Scheduler s = new Scheduler();
s.schedule("0 5 * * *", new Runnable() {
public void run() {
//call your function
TestClass tc = new TestClass(value);
}
});
// Starts the scheduler.
s.start();
try {
Thread.sleep(1000L * 60L * 10L);
} catch (InterruptedException e) {
;
}
// Stops the scheduler.
s.stop();
This code calls the class at 5:00:00 everyday, but I'm not sure what to pass in Thread.sleep()
I need to write for multiple different times too and make sure it runs for a long time, i.e. over a year.