Concurrency means working on multiple computations during overlapping periods. It keeps user interfaces responsive, lets applications handle several network requests, and allows servers to continue serving other requests while one runs. section 1.2.4 section 14.0
suspend fun processUser(credentials: Credentials) {
val user = authenticate(credentials) #1
val data = loadUserData(user) #2
val profilePicture = loadImage(data.imageID) #3
// ...
}
suspend fun authenticate(c: Credentials): User { /* ... */ } #4
suspend fun loadUserData(u: User): Data { /* ... */ }
suspend fun loadImage(id: Int): Image { /* ... */ }
A suspending processUser function reads sequentially while each network call suspends without blocking its underlying thread. section 1.2.4
Concurrency does not require physical simultaneity: a single CPU core can interleave tasks. Parallelism executes tasks physically at the same time on multiple cores; Kotlin coroutines support both. section 14.1
Loading images concurrently
async starts loading two images independently, await waits for both results, and combineImages produces the final image inside a coroutineScope. section 1.2.4
Kotlin structures concurrent work with:
- Suspending functions, which pause execution and resume later without changing sequential-looking code. section 14.9
- Coroutine builders such as runBlocking, launch, and async, which create coroutine computations. section 14.9
- Dispatchers and withContext, which select or switch the thread or thread pool used for execution. section 14.9






















