Skip to content

Instantly share code, notes, and snippets.

@deepankarb
Created June 28, 2016 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepankarb/4e8abca00107f4e4087a5c0a0a5c21dc to your computer and use it in GitHub Desktop.
Save deepankarb/4e8abca00107f4e4087a5c0a0a5c21dc to your computer and use it in GitHub Desktop.
Execute runnables on the ui thread in a loop
private void loop(Deque<Runnable> rs, int delay) {
final Runnable first = rs.removeFirst();
new Handler().post(first);
rs.addLast(first);
new Handler().postDelayed(() -> loop(rs, delay), delay);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment