I don't have experience with cron4j scheduler and I need to schedule tasks with different time. Use cron4j is requirement, so I have to use it. I've tried to find tutorial but unsuccessfully. Can someone help me. I don't want full code here now, just recommendation how to do that or link with tutorial. I've read cron4j documentation, but I've not found what I need. I appreciate every help. Thanks.
Asked
Active
Viewed 4,602 times
2 Answers
2
Sorry I'm late to the party.
This is exactly the question I struggled with on this thread
However I managed to find 'a' way to implement multiple schedules.
If you have different tasks you want to execute at different times. Create different schedulers:
// Creates a Constituent Scheduler instance.
Scheduler myFirstScheduler = new Scheduler();
// Creates a Summary Scheduler instance.
Scheduler mySecondScheduler = new Scheduler();
// Schedule a once-a-week task at 8am on Sunday.
myFirstScheduler("0 8 * * 7", new Runnable() {
public void run() {
//DO SOMETHING
}
});
//Schedule a twice a day task at 7am and 6pm on weekdays
mySecondScheduler("0 7 * * 1-5 |0 18 * * 1-5 ", new Runnable() {
public void run() {
//DO SOMETHING
}
});

Community
- 1
- 1

TheMightyLlama
- 1,243
- 1
- 19
- 51
-
2No need to make separate objects. You can call schedule() method multiple times with different schedule time specified. – Half Blood Prince Jun 03 '16 at 10:29