• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Rescheduling a Timer Task

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have made a custom timertask class by extending the java.util.TimerTask, and a singlton timer class by extending the java.util.Timer (as i need only one timer object).Now what i am doing is scheduling repititivly my custom timertask with the timer object using the method-- timer.schedule(repSchedularObj, delay); Now i want to give user the authority to change the delay so that he/she can reschedule it(by giving a user interface to enter a delay).

Can any one suggest how to do it ?

How to check if previously(before changing the delay) the task is running or not and if running how to get the object of the previously runnig task in order to cancel it ?
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really need to cancel a running job? It would seem to make more sense to just schedule the next iteration after the new delay. So you could just call cancel() on the TimerTask (a reference to which you should have stored somewhere), and then schedule it anew.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic