在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 } 参考
Original:http://www.intertech.com/Blog/android-non-ui-to-ui-thread-communications-part-2-of-5/ his is the second part of my series of blog posts on Android non-UI thread-to-UI thread communications. See herefor the start of the series. As a refreshe
Android UI线程和非UI线程 UI线程及Android的单线程模型原则 当应用启动,系统会创建一个主线程(main thread). 这个主线程负责向UI组件分发事件(包括绘制事件),也是在这个主线程里,你的应用和Android的UI组件(components from the Android UI toolkit (components from the android.widget and android.view packages))发生交互. 所以main thread也叫UI