What is the difference between a Thread and a Handler

前端 未结 3 1183
故里飘歌
故里飘歌 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:24

    A thread defines a process running. Like you have a main (UI thread) in android. and all other threads run in background.(in parallel).

    Handler is completely different, it is like initiating the task defined in a handler..

    To clear out your confusion, and perform threading in android you must read : http://android-developers.blogspot.com/2009/05/painless-threading.html

    and i would suggest AsyncTask instead of using Thread in all cases.

提交回复
热议问题