Skip to content

Instantly share code, notes, and snippets.

@ducalpha
Created August 18, 2013 05:55
Show Gist options
  • Save ducalpha/6260118 to your computer and use it in GitHub Desktop.
Save ducalpha/6260118 to your computer and use it in GitHub Desktop.
multithreading on Android
/* Tradditional Java thread */
Handler mHandler = new Handler();
private final Runnable mRunnable = new Runnable() {
public void run()
{
updateTotalRxBytes();
mHandler.postDelayed(mRunnable, 1000); // repeat after 1000ms
}
};
public void onButtonClicked() {
mHandler.postDelayed(mRunnable, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment