This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Timers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Timers" Watch "Timers" New topic
Author

Timers

Ahmed Basheer
Ranch Hand

Joined: Apr 15, 2004
Posts: 77
I have a need of a timer which is resettable. Once it is scheduled for say 2 minute, before 2 minute are over I should be able to reschedule it for runing for 1 more minute.
Swing timers have this capability, because they have restart method. I would avoid using swing timers in non-gui application. I can't use ELB Timer service because I am running in plain java 1.5. Some new features in Java 1.5 offer some promise but have not explored yet.

Appreciate your suggestions.
Basheer
Rahul Sapkal
Greenhorn

Joined: Jul 06, 2005
Posts: 4
Basheer,
You can use java.util.Timer class to achieve this.

Rahul.
Ahmed Basheer
Ranch Hand

Joined: Apr 15, 2004
Posts: 77
Well, java.util.TimerTask which are scheduled through java.util.Timer don't have capability to be resetted. There is no reset method on Task once it is scheduled.
Thanks,
Basheer
Doug Trott
Greenhorn

Joined: Jan 18, 2005
Posts: 2
Perhaps "resetting" the timer can be viewed as simply a functional requirement? I used the Java.util.Timer and canceled then recreated its task. It appears that the timer is being rescheduled, but it's really a new object.
 
jQuery in Action, 2nd edition
 
subject: Timers
 
Similar Threads
Gui animation
Timers
Java EE timer service and periodical jobs
Not able to update JTextPane in TreeSelectionListener Action
Timer Service