An Introduction to Asynchronous Code on Android

Many programming languages rely on the concept of a thread for work that runs in the background – or, as it is often called, asynchronously. Threads are responsible for managing execution of your program. A thread has a sequence of instructions that it executes, performing them in the order they are declared in.

An individual thread can only do so much work in a set period of time, so to keep the system responsive to the user while also performing complicated tasks, developers distribute work across many threads. On an individual device, the system can have multiple threads, and each of those threads can execute their instructions simultaneously.

The primary thread, which manages ...

Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.