Questions
KotlinIntermediate4 min
Why Coroutines are lightweight?
Answer
Coroutines are lightweight because they do not map 1:1 to native OS threads.
- Suspension vs Blocking: When a coroutine suspends (e.g., `delay(1000)`), it doesn't block the thread. It simply saves its state (local variables, instruction pointer) and releases the thread back to the pool.
- Reuse: One thread can execute many coroutines. While one is waiting for network, the thread can execute another.
- Stackless: They don't require a dedicated stack frame in the OS for each instance, unlike threads which reserve significant memory (often 1MB) just to exist.
1:1 Mentorship
Get personalized guidance from a Google Developer Expert. Accelerate your career with dedicated support.
Personalized Learning Path
Mock Interviews & Feedback
Resume & Career Guidance
Share & Help Others
Help fellow developers prepare for interviews
Sharing helps the Android community grow 💚