From the course: Kotlin Essential Training: Object-Oriented and Async Code
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Understanding coroutines - Kotlin Tutorial
From the course: Kotlin Essential Training: Object-Oriented and Async Code
Understanding coroutines
- [Instructor] Coroutines are Kotlin's primary abstraction for writing multithreaded asynchronous code. Understanding the core concepts behind coroutines will help us in learning how to use Kotlin's coroutine APIs in our application code. Coroutines are not a new concept. The term coroutines was coined in the 1950s as a means of describing a subroutine that could be suspended and resumed. This concept has since been implemented in many languages, including C++, C#, Rust, and of course Kotlin. In Kotlin, the Standard Library provides a few low-level APIs for coroutines, while most of the functionality is provided by the kotlinx.coroutines library. The library is actually publicly available on GitHub and can be viewed as a great resource for getting started or for learning more about coroutines implementation. In Kotlin, coroutines can be thought of as lightweight threads. Like a thread, a coroutine allows us to run a block of…