java - How do I use a timer to run code again and again until a boolean value e.g. Testing is equal to true? -


this easy question but, how use timer run code again , again until boolean value e.g. testing equal true?

obviously use while loop don't want stop rest of work taking place on main ui thread

if process running simultaneously, use handler , use postdelayed(runnable, long) post callback implementing runnable interface.

a rather naive example:

final handler = new handler();  final runnable r = new runnable() {     public void run() {     if (<expression>) {         // evaluated true, stuff , exit polling loop.     } else {         handler.postdelayed(this, <timeout>);     } }  handler.postdelayed(r, <timeout>); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -