Looper, Handler & Threading
ANDROID › System
Drills how the main-thread message loop dispatches work and what triggers ANRs.
Interviewers use this topic to check whether you understand Android's single-threaded UI model and the Looper/Handler/MessageQueue machinery beneath coroutines and the main thread. You'll be tested on how work is scheduled onto threads, why the UI thread must never block, and how to diagnose ANRs. Strong answers connect the low-level primitives to modern tools like coroutine dispatchers and WorkManager.
What this covers
- How Looper, MessageQueue, and Handler cooperate to process messages on one thread
- Preparing a Looper on a background thread and why HandlerThread exists
- Posting Runnables/Messages to the main thread and scheduling delayed work
- What causes ANRs (blocked main thread) and the time thresholds involved
- Why the no-arg Handler constructor is deprecated and how to bind a Looper explicitly
- How modern abstractions (coroutine dispatchers, WorkManager) sit on top of these primitives
Study this topic
- Looper, Handler & Threading explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Looper, Handler & Threading interview questions and answers