Skip to Main Content
Learning Concurrency in Kotlin
book

Learning Concurrency in Kotlin

by Miguel Angel Castiblanco Torres
July 2018
Intermediate to advanced content levelIntermediate to advanced
266 pages
7h 11m
English
Packt Publishing
Content preview from Learning Concurrency in Kotlin

Coroutines

Kotlin's documentation often refers to coroutines as lightweight threads. This is mostly because, like threads, coroutines define the execution of a set of instructions for a processor to execute. Also, coroutines have a similar life cycle to that of threads.

A coroutine is executed inside a thread. One thread can have many coroutines inside it, but as already mentioned, only one instruction can be executed in a thread at a given time. This means that if you have ten coroutines in the same thread, only one of them will be running at a given point in time.

The biggest difference between threads and coroutines, though, is that coroutines are fast and cheap to create. Spawning thousands of coroutines can be easily done, it is faster ...

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

Reactive Programming in Kotlin

Reactive Programming in Kotlin

Rivu Chakraborty
Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen

Publisher Resources

ISBN: 9781788627160Supplemental Content