Skip to content

Instantly share code, notes, and snippets.

@julianfalcionelli
Created May 15, 2017 00:01
Show Gist options
  • Save julianfalcionelli/63d3690021a043884c81c62dae639d4c to your computer and use it in GitHub Desktop.
Save julianfalcionelli/63d3690021a043884c81c62dae639d4c to your computer and use it in GitHub Desktop.
Handler & Thread - Alternative 2
//...
final Handler handler = new Handler();
final Runnable uiRunnable = new Runnable() {
@Override
public void run() {
mTextView.setText(mResult);
}
};
Thread thread = new Thread(new Runnable() {
public void run() {
mResult = performBlockingTask();
handler.post(uiRunnable);
}
});
thread.start();
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment