Questions
KotlinIntermediate4 min
Delay vs Thread.sleep?
Answer
Thread.sleep()
- Blocking: Pauses the entire thread.
- Cost: Expensive. The thread cannot do any other work.
- Context: Java / Standard threads.
delay()
- Suspending: Pauses the coroutine, not the thread.
- Benefit: The thread is released to the pool and can execute other coroutines while waiting.
- Context: Only available inside coroutines.
Always use `delay()` inside coroutines.
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 💚