Questions
KotlinIntermediate4 min
Difference between Coroutine and Java Thread?
Answer
| Feature | Java Thread | Kotlin Coroutine |
|---|---|---|
| Weight | Heavyweight (OS managed) | Lightweight (User-space managed) |
| Memory | ~1MB stack per thread | ~KB per coroutine |
| Creation | Expensive | Cheap |
| Blocking | Blocks the thread when waiting | Suspends (frees thread) when waiting |
| Context Switching | OS Kernel switch (expensive) | Software switch (fast) |
| Scalability | Limited (thousands max) | Massive (millions possible) |
Key Concept: Coroutines are "computations that can be suspended". They can pause execution without blocking the underlying thread, allowing that thread to do other work.
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 💚