Inside Android asynchronous processing: Understanding the Event Loop
summary
Demonstrates how Android’s single UI event loop (Looper, Handler, Message, Runnable) gets blocked by long-running work using a toy app that computes slow Fibonacci and sleeps to produce dropped frames and an ANR. Shows fixes using threads, ExecutorService (pooled vs serial), Future, AsyncTask (including its default serial-executor pitfall), and Kotlin Coroutines (with Anko) and compares submit/cancel semantics and conciseness. References Android framework source and java.util.concurrent for implementation details.
AI-written summary · about
chapters (12)
- 0:00Event Loop introduction
- 2:09UI performance issues
- 3:15What is the Event Loop
- 5:59How Handler works
- 8:50Blocking UI consequences
- 11:21Heavy processing solutions
- 13:12Handler alternatives
- 15:40Using ExecutorService
- 18:56AsyncTask simplification
- 21:28AsyncTask pitfalls
- 23:56Coroutines as alternative
- 26:23Further reading
related talks
29mLooper.loop() - Understanding Android's Message Queue
30mExtra! Extra! Thread all about it!
30mExtra! Extra! Thread all about it!
37mAndroid Suspenders
31mEffective Procrastination
40mBuilding Asynchronous Mechanisms in Android App, Using Kotlin Coroutines
35mEfficient Async with Kotlin Coroutines
33mUntangle your App: Efficient Threading in Android
