What is the difference between Handler, Runnable, and Threads?
While I was working with android, and I need something to run in the background. I use Threads to run it. Usually I would write a class that extends Thread and implement the run method.
I have also saw some examples that implments runnable and pass into runnable into Threads.
However I am still confused. Can someone give me a clear explanation?
- What is the point of Runnable if one can write the background code in the Thread's run method?
- How is Handler used inside thread and why do we need to use it.
- Android has another thing call runOnUiThread, How do we use that? I know that it is used for updating the UI.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…