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 ...

Get Asynchronous Android now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.