-
-
Save deepankarb/4e8abca00107f4e4087a5c0a0a5c21dc to your computer and use it in GitHub Desktop.
Execute runnables on the ui thread in a loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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