Chapter 3. Distributing Work with Handler and HandlerThread
In Chapter 2, Staying Responsive with AsyncTask, we familiarized ourselves with the most well-known concurrency construct of the Android platform. What is perhaps less well known are the mechanics of how AsyncTask coordinates work between background threads and the main thread.
In this chapter we'll meet some of the lower-level constructs that AsyncTask builds on to get its work done.
We'll see how to defer tasks to happen in the future on the main thread, whether that is as soon as possible, after a specified delay, or at a specified time, and we'll apply the same concepts to scheduling work on background threads and coordinating the results with the main thread.
In this chapter we will cover the following topics:
Understanding
LooperBuilding responsive apps with
HandlerScheduling work with
postCanceling a pending
RunnableScheduling work with
sendCanceling pending Messages
Multithreaded programming with
HandlerBuilding responsive...