By now, you have developed a deep understanding of Kotlin as a language and its conventions. In this part of the book, you’ll learn how to perform concurrent programming in Kotlin.
Concurrency is an impactful topic no matter whether you are writing server-side, mobile, or desktop applications with Kotlin. Most modern applications need to do more than one thing at once, be it serving or making network requests, keeping a responsive user interface while performing CPU-intensive tasks, or allowing users to multitask in other ways. As a Kotlin developer, you’ll come across and work with concurrent code in Kotlin sooner or later, as well.
Kotlin comes with a unique and robust approach for concurrent programming based on the concept of coroutines, a lightweight abstraction that works on top of threads. The core primitives for concurrent programming are built right into the language, and its capabilities are extended by the kotlinx.coroutines library, which is being developed at JetBrains. Many libraries in the Kotlin ecosystem have fully embraced Kotlin’s coroutines-based concurrency model and expose idiomatic and non-blocking APIs for you to use. Gaining an understanding of the concepts used by these APIs allows you to make use of these libraries to their fullest potential.