Kotlin Android Coroutine Context: Default Dispatcher vs Commonpool

July 24, 2018

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'
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.