0

Hi,

I'm trying to find out how to call a method from another class every 0.5 seconds until I tell it to stop using a function from the same class (the class that is doing the calling). Does anyone know if this is even possible? I've done a few Internet searches and tried to write the code but I've come up with nothing substantial. Could anyone please show me how to do this. Some sample code would be appreciated. This is just highlighting my programming weaknesses. Thank you very much.

SasukeUchiha.

3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by BestJewSinceJC
0

All the links Vernon pointed you towards are Timer related, it seems like. His may be a better solution than what I'll show you, but there is another way to do it pretty easily:

Use Thread.sleep(milliSeconds);
Then call whatever method it is you wanted to run every five seconds. You can do this in a while loop, and one simple way you could exit the while loop is with a boolean that changes to false when you want to stop calling the method.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.