Difference between the main thread and UI thread

前端 未结 5 1675
醉梦人生
醉梦人生 2020-12-12 15:20

I\'m given to understand that both are the same. But I recently(a bit late to the party) came across android support annotations . The note in the same reads

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 15:29

    Simple Answer is Your main thread in also the UI thread.

    As such, the main thread is also sometimes called the UI thread. As stated in Android documentation's thread portion of Processes and Threads. Android Documentation

    Moreover, UI toolkit is not thread safe and must not be dealt with worker threads. I am again quoting Android Documentationas it is the reference guide for Android that:

    Thus, there are simply two rules to Android's single thread model:

    1.Do not block the UI thread

    2.Do not access the Android UI toolkit from outside the UI thread

    Hope I answer what you ask for.

提交回复
热议问题