Kotlin Coroutines: Fundamentals
Learn the fundamentals about threads and coroutines, along with the basics of the Kotlin Coroutines framework. By Filip Babić.
Learning path
This is part of the Android Data & Networking learning path. View path.
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
- Background processing
- Worker Threads
- Main or UI Thread
- Runnables
- Posting data to the UI
- Kotlin Coroutines
- Coroutine Builders
- Dispatchers
- Thread pools
- Suspending
- Nested coroutines
Part 1: Beginning Threads
Learn about blocking calls, background processing, creating threads and why using coroutines is increasingly popular!
Explore the project structure and functionality, run the project to see the UI, and prepare for next episodes.
Use an HTTP connection and an input stream, to download a cute owl image and display it in your app.
Create threads to move the blocking work away from the main thread, to the background.
Post the result to the main thread, using native Android mechanisms - Handlers and runOnUiThread().
Review the concepts learned so far, and prepare for the next part of the course - Kotlin Coroutines!
Part 2: Beginning Coroutines
Get started with some basic theoretical concepts of Kotlin Coroutines, and why they are becoming increasingly popular.
Launch a coroutine, using coroutine builders, and learn how to replace manual thread creation.
Use different dispatchers, to change the threads in coroutines, and learn what each dispatcher has to offer.
Learn how to post the data to the main thread, from anywhere, using the main dispatcher.
Review all the information about threading and coroutines you've gained, and learn about future courses you can explore on the topic!