首页 > 移动平台 > 详细

Android 判断当前thread 是否是UI thread

时间:2016-10-05 10:39:38      阅读:227      评论:0      收藏:0      [点我收藏+]

   在Android 中判断当前的Thread是否是UI Thread 的方法:

  1.    

if (Looper.myLooper() == Looper.getMainLooper()) {
    // Current thread is the UI/Main thread
}        
 

  2.

if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
    // Current thread is the UI/Main thread
}

 

 参考如下文章:其中还讲到了  runOnUiThread()  方法的用法。

http://codetheory.in/checkdetect-whether-current-thread-uimain-thread-android/

http://lak4cyut.blogspot.jp/2011/03/android-tip-activityrunonuithread.html

Android 判断当前thread 是否是UI thread

原文:http://www.cnblogs.com/igoogleyou/p/androidoo.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!