What is the difference between a Thread and a Handler

前端 未结 3 1236
故里飘歌
故里飘歌 2021-02-05 07:08

I\'m trying to find out the difference between a thread and a handler. Does creating a new handler create a new thread?. When a new handler is run using post(), is it creating a

3条回答
  •  半阙折子戏
    2021-02-05 07:32

    Why we use handlers with thread :

    When we install an application in android then it create a thread for that application called MAIN UI Thread, All activities run inside that thread , By the android single thread model rule we can not access UI elements (bitmap , textview etc..) directly for another thread defined inside that activity.

    So if want to access Main UI Thread elements by another thread then we will use handlers.

提交回复
热议问题