🚀 Enrollments Open for 1:1 Mentorship Scheduled as per your availability 💚Book Now
KotlinIntermediate4 min
What are Dispatchers and name all of them?

Answer

Dispatchers determine which thread or thread pool a coroutine runs on.

  1. Dispatchers.Main

    • Thread: The main (UI) thread.
    • Use for: UI updates, handling user interactions.
  2. Dispatchers.IO

    • Thread: A shared pool of on-demand threads (64 or more).
    • Use for: Blocking I/O operations (Network, Database, File reading/writing).
  3. Dispatchers.Default

    • Thread: A shared pool of threads optimized for CPU work (size = number of CPU cores).
    • Use for: CPU-intensive tasks (Sorting lists, parsing JSON, complex calculations).
  4. Dispatchers.Unconfined

    • Thread: Starts in the current thread, but resumes in whatever thread the suspending function finished on.
    • Use for: Testing or very specific edge cases. rarely used in general app code.

Want to go deeper?

Read our full guides and blog posts on Kotlin and related Android topics.

Want to master these concepts?

Join our live cohorts and build production-ready Android apps.

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

Limited slots available each month

Share & Help Others

Help fellow developers prepare for interviews

Sharing helps the Android community grow 💚