• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to check if a timer is still running or not ???

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

I have a timer configured to run on a timer task object as the below code :


In case the SimpleRunnable thrown a run time exception and that run time exception was not caught, the timer will stop from executing at regular intervals.

Is there any APIs to check if the timer is still running and operating or do I have to implement this functionality myself.


Thanks in advance

[Nitesh: Added CodeTags]

 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Timer does not give such advanced features but a ScheduledExecutorService does! It returns a future upon successful submission which you can query to get the task status.
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, before asking this question, I have already implemented my own solution [from scratch] to know if a timer is still running or not.

But it is good idea in software development, to see if others have better solutions or ideas.

Personally, when dealing with core applications and real time applications, I'd rather developing components and implementing such functionalities myself

 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Khaled Mahmoud wrote:Personally, when dealing with core applications and real time applications, I'd rather developing components and implementing such functionalities myself


I generally agree. However, when it comes to concurrency I'm all for using code written by someone much cleverer than me.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest that you take a look at the Swing Timer. It's really easy to use and has many features.
reply
    Bookmark Topic Watch Topic
  • New Topic