Can somebody tell me the deference between Thread and Handler? When we use Thread and when we use Handler?
I have two code in my project , But I can\'t understand th
Threads:
You can use the new Thread for long-running background tasks without impacting UI Thread. From java Thread. But here you can't update the UI from Thread.
Since normal Thread is not much useful for Android architecture, helper classes for threading have been introduced. You can find answers to your queries on the Threading performance documentation page.
Handler:
This class is responsible for enqueuing any task to the message queue and processing them. Each Handler can be associated with one single thread and that thread’s message queue.
There are two main uses for a Handler:
Looper: Looper is a worker that keep a thread alive, It loops over message queue and send the message to respective Handler.
Message Queue: This class holds the list of messages to be dispatched by the looper. You can just call Looper.myqueue() to get list of messages. We do not normally deal with it.