I have a requirement to pause a while loop for a specific number of milliseconds. I have tried using Thread.sleep(duration) but it is not accurate, especially in a looping s
The solution is to use a handler with a runnable and use of the method 'postDelayed'. Example:
new Handler().postDelayed(new Runnable() { public void run () { // Do delayed stuff! } }, 5000L); //5 seconds delay
https://stackoverflow.com/a/21680858