Hi all,

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, 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.

Do you have to continually check the database for the date? Or does it stay the same once you have read it?
If the date that is read is unchanged after you read it, you could use a Timer to call a listener after waiting the time from now to the time to send the emails.

Edited 5 Years Ago by NormR1: n/a

Do you have to continually check the database for the date? Or does it stay the same once you have read it?
If the date that is read is unchanged after you read it, you could use a Timer to call a listener after waiting the time from now to the time to send the emails.

A user could change the date stored in the database, so yeah, the system would have to check the database for any of such changes.

However, i still dont understand your timer suggestion. If the timer is running, how can the user do other things on the system? Won't the timer could have to completely run first before the user can continue with anything else?

It would if you did your own timer in a loop, but you can use a java.util.Timer to schedule a future call to your method, and that will use the system clock to wait until the right time. While it's waiting it uses zero resources, so it will have no impact on how the rest of your code runs.

Edited 5 Years Ago by JamesCherrill: n/a

A user could change the date stored in the database, so yeah, the system would have to check the database for any of such changes.

Does the program have to continually check the stored date to see if it has been changed?
If the program can't be automatically notified that the stored date has been changed, then the problem becomes very difficult to solve.

Does the program have to continually check the stored date to see if it has been changed?
If the program can't be automatically notified that the stored date has been changed, then the problem becomes very difficult to solve.

No, actually, once the stored date is changed, the system will be notified (I think that's much better).

This article has been dead for over six months. Start a new discussion instead.