First of all Hi to everyone, as this is my first post here !
I'm writing (trying) a simple java app that could make a db query, fetch result and display message on the screen ... and do it every 5 min . I've got everything working except those 5 min ... I need to pause timer somehow, and start next delay (period) again only after a button has been pressed. Now if I don't press OK button for let's say 2h, I'll need to press it about 24 (2h/5min delay) times ... I hope I made myself clear ...
Can anyone give me an advice? Is java.util.Timer a good solution ?
Then you should take a look at the java.util.concurrent package and the class ScheduledExecutorService.
There you find what you are looking for. Using timers is "old school".
Also... never EVER do any real work in the main-method. That method is there to initiate the real work and should only contain the code needed to start your application (reading application properties, setting up loggers, setting up data sources and stuff like that). [ December 05, 2008: Message edited by: Ove Lindstr�m ]