Created
March 2, 2022 02:12
-
-
Save teocci/4428104b11e219320a49a6db6c9cd0ee to your computer and use it in GitHub Desktop.
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
ExecutorService executor = Executors.newSingleThreadExecutor(); | |
Handler handler = new Handler(Looper.getMainLooper()); | |
executor.execute(() -> { | |
//Background work here | |
handler.post(() -> { | |
//UI Thread work here | |
}); | |
}); |
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
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