Skip to content

Instantly share code, notes, and snippets.

@ikew0ng
Created December 23, 2013 06:19
Show Gist options
  • Save ikew0ng/8092451 to your computer and use it in GitHub Desktop.
Save ikew0ng/8092451 to your computer and use it in GitHub Desktop.
检查方法是否运行于主线程
private void throwIfNotOnMainThread(){
if (Looper.myLooper() != Looper.getMainLooper()) {
throw new IllegalStateException("Must be invoked from the main thread.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment