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

Concurrency is not parallelism

There's common confusion as to what the difference between concurrency and parallelism is. After all, both of them sound quite similar: two pieces of code running at the same time. In this section, we will define a clear line to divide both of them.

Let's start by going back to our non-concurrent example from the first section:

fun getProfile(id: Int) : Profile {    val basicUserInfo = getUserInfo(id)    val contactInfo = getContactInfo(id)    return createProfile(basicUserInfo, contactInfo)}

If we go back to the timeline for this implementation of getProfile(), we will see that the timelines of getUserInfo() and getContactInfo() don't overlap.

The execution of getContactInfo() will happen after getUserInfo() has finished, ...

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