Kotlin Coroutines: Fundamentals
Learn the fundamentals about threads and coroutines, along with the basics of the Kotlin Coroutines framework. By Karol Wrótniak.
Who is this for?
Beginner Android developers who want to learn about threading, what coroutines are, and how to launch a coroutine in Android.
Covered concepts
- Blocking & Non-Blocking calls
- Synchronous vs. Asynchronous code
- Threads
- Main or UI Thread
- Posting data to the UI
- Kotlin Coroutines
- Coroutine Builders
- Dispatchers
- Jobs
- Suspending functions
- Coroutine contexts
- Coroutine scopes
- Nested coroutines
Part 1: Getting started with Coroutines
Learn about blocking calls, background processing, creating threads and why using coroutines is increasingly popular!
Discover the purposes of coroutines, and how they can help you write asynchronous code in a simple way.
Learn about suspending functions, differences between suspending and blocking functions, and how delay() works.
Implement a simple coroutine calling a suspending function, and learn how to use the suspend modifier in practice.
Part 2: Deep Dive into Coroutines
Understand the coroutine contexts and dispatchers, and how to choose the right ones for your needs.
Use Coroutine Builders: launch, async, runBlocking.
Learn about coroutine scopes and the structured concurrency in Kotlin Coroutines.
Understand the coroutine jobs, their hierarchy and learn how to cancel a coroutine and its children.
Learn about async/await, how to use them to execute multiple coroutines in parallel.
Learn about coroutine exception handlers, and how to debug the coroutines.
Toggle description
Use all the knowledge you’ve gained to implement an API call using coroutines with exception handling in a composable.