~/talk

Coroutines vs. Threads: The True Cost of a Context Switch

Talkat AndroidMakers by droidcon 2026 · on Friday, 2026-04-10· at 13:30· [android]
slides:none on file

Explains that crossing the user→kernel boundary triggers a syscall and kernel trap where the OS saves registers and TCBs, flushing CPU caches; a raw thread carries a 1–2 MB thread stack and kernel-managed overhead, so a few hundred threads exhaust memory and cause cache-miss storms. Coroutines save tiny continuation objects on the heap (a few hundred bytes), use cooperative scheduling, and avoid context switches; a live demo with Android Studio Profiler contrasts crashing at hundreds of threads versus launching 100,000 coroutines quickly and with low memory.

AI-written summary · about

  1. 0:00Coroutines and context switches
  2. 7:05Threads are inefficient
  3. 13:02Coroutines avoid kernel overhead
  4. 16:58Live demo: coroutines vs threads
  5. 25:14Structured concurrency
  6. 31:14Choosing dispatcher
  7. 33:42Dispatcher selection scenarios
  8. 37:15Key takeaways
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.