Kotlin 2 · Coroutines
Switch dispatcher
Run blocking or CPU-heavy work on a suitable dispatcher without blocking the caller.
val text = withContext(Dispatchers.IO) { File("data.txt").readText() }
Official Kotlin 2 documentation
Kotlin 2 · Coroutines
Run blocking or CPU-heavy work on a suitable dispatcher without blocking the caller.
val text = withContext(Dispatchers.IO) { File("data.txt").readText() }
Official Kotlin 2 documentation
Was this page helpful?