aspose file tools*
The moose likes Threads and Synchronization and the fly likes How to check if a timer is still running or not ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "How to check if a timer is still running or not ???" Watch "How to check if a timer is still running or not ???" New topic
Author

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

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
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]


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

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.


apigee, a better way to API!
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
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

Joined: May 27, 2008
Posts: 225

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

Joined: Jan 09, 2005
Posts: 74
I suggest that you take a look at the Swing Timer. It's really easy to use and has many features.


Share Knowledge to gain it.<br /> <br />SCJP 1.2, SCDJWS 1.4, SCWCD 1.4, SCBCD 1.3, ICAD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check if a timer is still running or not ???