Android判断是否在主线程

来源:互联网 发布:勇者盟约精灵升星数据 编辑:程序博客网 时间:2024/05/18 01:06

下面三个方法都可以判断当前线程是否在主线程

1public boolean isMainThread() {    return Looper.getMainLooper() == Looper.myLooper();}2public boolean isMainThread() {    return Looper.getMainLooper().getThread() == Thread.currentThread();}3public boolean isMainThread() {    return Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId();}
阅读全文
0 0
原创粉丝点击