Android 如何判断当前线程是否是主线程

2017-10-15  本文已影响167人  404Error
public boolean isMainThread() {
    return Looper.getMainLooper() == Looper.myLooper();
}
public boolean isMainThread() {
    return Looper.getMainLooper().getThread() == Thread.currentThread();
}
public boolean isMainThread() {
    return Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId();
}
上一篇 下一篇

猜你喜欢

热点阅读