I have a daemon thread which wakes up at a specified interval to do some task. Now I need to add two more tasks to the thread & these tasks have their own intervals. Something like
- After every x seconds do Task1
- After every y seconds do Task2
- After every z seconds do Task3
So I basically need to come up with a sleep logic to ensure that all the tasks are done at the right time. What would be the most optimal way of doing this? My thought on this was that, the times at which each task is performed is an Arithmetic Progression, so I would need to combine the AP's corresponding to each task & use that series to figure out the time interval I need to sleep as well as the next task to perform. Does this approach make sense?