• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • 0
  • Mark post as helpful
  • send pies
  • 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]

 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Nadeem Awad
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic