Browse topics
Kotlin Coroutines
Dispatchers
Main, IO, Default dispatchers and withContext for thread switching.
coroutine dispatchersDispatcher Main in KotlinDispatchers.Main runs coroutines on UI thread in Android/UI apps. A Kotlin example with source code and sample output.coroutine dispatchersDispatcher IO in KotlinDispatchers.IO is optimized for blocking I/O operations. A Kotlin example with source code and sample output.coroutine dispatchersDispatcher Default in KotlinDispatchers.Default is for CPU-intensive work. A Kotlin example with source code and sample output.coroutine dispatcherswithContext Dispatcher in KotlinwithContext switches coroutine to another dispatcher and returns result. A Kotlin example with source code and sample output.coroutine dispatchersCustom Dispatcher in KotlinCustom dispatchers can be created using Executors and asCoroutineDispatcher(). A Kotlin example with source code and sample output.
Related topics
Coroutine Basics Introduction, suspend functions, launch, runBlocking and coroutine scope. Async & Await async builder, await, parallel work and exception handling. Kotlin Flow Cold flows, operators, StateFlow and SharedFlow basics. Advanced Coroutines Coroutine cancellation, channels and producer-consumer patterns.