public class ThreadUtils{
// 方法1
public static boolean isMainThread() {
return Looper.getMainLooper() == Looper.myLooper();
}
// 方法2
public static boolean isMainThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
// 方法3
public static boolean isMainThread() {
return Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId();
}
}