Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sean Michael Hayes
Ranch Hand
Posts: 54
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
21
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sean Michael Hayes
Ranch Hand
Posts: 54
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic