Skip to Main Content
Hands-On Object-Oriented Programming with Kotlin
book

Hands-On Object-Oriented Programming with Kotlin

by Abid Khan, Igor Kucherenko
October 2018
Intermediate to advanced content levelIntermediate to advanced
370 pages
9h 15m
English
Packt Publishing
Content preview from Hands-On Object-Oriented Programming with Kotlin

What are coroutines?

Coroutines are components of a computer program that can be considered lightweight threads. Coroutines allow us to suspend the invocation of a function without blocking a thread. Let's imagine a case in which you need to perform a request on the server and display a progress bar until your app receives the response. A request is a long-term operation that should be performed asynchronously because a user interface should stay responsive. This is a common approach to running a new thread that uses a callback so that you're notified when the app receives a response. However, using code with callbacks looks unnatural, complex, and can lead to bugs.

Coroutines can be considered as a library that wraps a particular part of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen
Learning Concurrency in Kotlin

Learning Concurrency in Kotlin

Miguel Angel Castiblanco Torres

Publisher Resources

ISBN: 9781789617726Supplemental Content