wood burning stoves*
The moose likes Android and the fly likes TimerTask stops if a condition in its run method is fulfilled? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "TimerTask stops if a condition in its run method is fulfilled?" Watch "TimerTask stops if a condition in its run method is fulfilled?" New topic
Author

TimerTask stops if a condition in its run method is fulfilled?

Sean Michael Hayes
Ranch Hand

Joined: Feb 08, 2012
Posts: 54

I've been looking at this problem for hours now and nothing seems to be clicking.

I have a local service to monitor the values retrieved using SNMP and compare them to stored values in object instance, if a value exceeds that amount defined in the instance, a telnet command is launched to that machine over the network.



In the monitor task, the run method shall run the performAction() method.



When the alerted() method is called by the alertObject, the timer seems to stop with it and shall not run again. Is the telnet command I'm launching from that instance interfering somehow?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

Are you saying that the method reaches line 21 (the curr.alerted() method) but does not reach line 22 (the Log statement)? If so then
1) I would check the logs to see if there is an error
2) If no error, then the curr.alerted() method must hang, blocking the Timer's thread from executing further. Figure out what makes it hang, and make it stop.

The DDMS tools which ship with the Android SDK should help you figure out the state of the timer's thread.


Steve
Sean Michael Hayes
Ranch Hand

Joined: Feb 08, 2012
Posts: 54

Steve Luke wrote:Are you saying that the method reaches line 21 (the curr.alerted() method) but does not reach line 22 (the Log statement)? If so then
1) I would check the logs to see if there is an error
2) If no error, then the curr.alerted() method must hang, blocking the Timer's thread from executing further. Figure out what makes it hang, and make it stop.

The DDMS tools which ship with the Android SDK should help you figure out the state of the timer's thread.


That was it, for the telnet, I parsed the text as it came in. I was asking it to read up to a word that actually never appears. Just telling it to disconnect when its action is sent fixed the issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TimerTask stops if a condition in its run method is fulfilled?
 
Similar Threads
Service being destroyed?
How to i invoke a method every 24 hours
java.lang.IllegalThreadStateException: Thread already started
Application nor run in the background
test bed for array based list implementation