Kotlin Android Coroutine Context: Default Dispatcher vs Commonpool

When you use launch or async without any arguments, it actually uses DefaultDispatcher.

DefaultDispatcher: It is currently equal to CommonPool, but the value is subject to change in the future.

For background tasks, use CommonPool or leave it blank.

For UI tasks (e.g. involve update for view), use UI from kotlinx-coroutines-android.

Edit build.gradle (Module).

dependencies {
    // https://github.com/Kotlin/kotlinx.coroutines/releases
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.23.4'
}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.