Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timers

 
Ahmed Basheer
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basheer,
You can use java.util.Timer class to achieve this.

Rahul.
 
Ahmed Basheer
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic