Android 判断当前thread 是否是UI thread
2024-08-29 21:57:05
在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
最新文章
- 探究@property申明对象属性时copy与strong的区别
- 论C#之多继承
- Ruby之基本数据类型(三)
- Oracle创建表空间、用户、授权
- 多线程更新UITableView时容易导致的问题
- angularjs指令系统系列课程(3):替换replace,内容保留transclude,作用方式restrict
- Content-Type: application/vnd.ms-excel";>;
- Possion 分布
- 学习opengl(起步)
- js文本框验证
- iOS崩溃日志分析-b
- libvirtsAPI
- 基于KMP与Levenshtein模糊匹配算法的银行联行号查询(转)
- Andrid 多线程下载
- php提供service总结---wsdl篇
- 使用ActionBar实现下拉式导航
- 201521123095《java程序设计》第4周学习总结
- HTML <;select>;标签
- Python基础:条件判断与循环的两个要点
- IIS 常用命令
热门文章
- C#实现麦克风採集与播放
- shell取余数
- windows phone 切换多语言时,商店标题显示错误的问题
- SecureCRT配置自动保存日志(实用)
- centOS7 配置DNS上外网
- 一款基于jQuery和HTML5全屏焦点图
- Can&#39;t zip RDDs with unequal numbers of partitions
- jQuery插件开发全解析<;转>;
- 2015 Multi-University Training Contest 3 1006 Beautiful Set
- MS SQL Server2012中的EOMONTH函数