🚀 Enrollments Open for Jetpack Compose Cohort 2 — 7 Days of Live Learning to Build Modern Android UIs 💚Join 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 master these concepts?

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

Accelerate Your Growth

Don't just learn concepts in isolation. Build production-ready Android apps with expert guidance.

Live Interactive Sessions
Code Reviews & Feedback
Real-world Projects
Career Guidance

Limited seats available for next cohort