Skip to content

Instantly share code, notes, and snippets.

@teocci
Created March 2, 2022 02:12
Show Gist options
  • Save teocci/4428104b11e219320a49a6db6c9cd0ee to your computer and use it in GitHub Desktop.
Save teocci/4428104b11e219320a49a6db6c9cd0ee to your computer and use it in GitHub Desktop.
ExecutorService executor = Executors.newSingleThreadExecutor();
Handler handler = new Handler(Looper.getMainLooper());
executor.execute(() -> {
//Background work here
handler.post(() -> {
//UI Thread work here
});
});
new Thread(() -> {
// do background stuff here
runOnUiThread(()->{
// OnPostExecute stuff here
});
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment