I want to run a java program that calls a function defined in it's class every hour. I've never done such a thing (only META refresh in HTML, hahaha). Could anyone point me how to do this? I would run the java program from the command line and the logic to do the calling would reside in the main().
I would recommend starting a separate thread rather than keeping everything in main().
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
David Duran
Ranch Hand
Joined: Feb 11, 2002
Posts: 122
posted
0
Thanks Marilyn! Clarification: Is it necessary to call the function before the try {...} block? Is the difference simply: function() ... 1 hour ... function() versus ...1 hour... function()?
Originally posted by David Duran: Clarification: Is it necessary to call the function before the try {...} block? Is the difference simply: function() ... 1 hour ... function() versus ...1 hour... function()?
Yes. That's the only difference.
David Duran
Ranch Hand
Joined: Feb 11, 2002
Posts: 122
posted
0
Thanks Matt, the Timer class looks like it would do the job but this code is going into an RMI server app which already extends UnicastRemoteObject. Since Timer requires a TimerTask object as one of the parameters to it's schedule functions that would mean I'd have to extend TimerTask (since it's abstract) within this class. Since I can't extend 2 classes I guess I can't use TimerTask and Timer (unless I'm mistaken). Right now I'm able to implement threads because I'm implementing Runnable as opposed to extending Thread.