I’m working on a system that does a bunch of stuff, as well as monitors the current date on a system, checks it against a stored date in a database, and if both dates are exactly the same, sends an email automatically to a bunch of users.
Now, I’ve been able to do everything else (the email sending, reading data from the database, you name it), except the monitoring part. What technique do I employ such that once the program is running, and the user is using the program, some part of that program is also carrying out checks on system date and the date stored in the database?
Any suggestions will be appreciated.
Thanks.
Instead of using scheduler (Quartz or cron), or start a thread at target time, I’d recommend you to use
ScheduledExecutorService.scheduleAtFixedRateto check periodically.Advantages against other approaches: 1. it will reflect latest DB change at the moment. 2. it is easier to implemnt. 3. the logic can be reused or unit tested