Skip to content

Instantly share code, notes, and snippets.

@jddeep
Created June 24, 2019 10:44
Show Gist options
  • Save jddeep/dd43bd39fc280feb0ceab514a9054ee8 to your computer and use it in GitHub Desktop.
Save jddeep/dd43bd39fc280feb0ceab514a9054ee8 to your computer and use it in GitHub Desktop.
private void feedMultiple() {
if (thread != null)
thread.interrupt();
final Runnable runnable = () -> addEntry();
thread = new Thread(() -> {
for (int i = 0; i < 1000; i++) {
// Don't generate garbage runnables inside the loop.
runOnUiThread(runnable);
try {
Thread.sleep(25);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread.start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment