Created
August 18, 2013 05:55
-
-
Save ducalpha/6260118 to your computer and use it in GitHub Desktop.
multithreading on Android
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
/* 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