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

Introduction to concurrency

Correct concurrent code is one that allows for a certain variability in the order of its execution while still being deterministic on the result. For this to be possible, different parts of the code need to have some level of independence, and some degree of orchestration may also be required. The best way to understand concurrency is by comparing sequential code with concurrent code. Let's start by looking at some non-concurrent code:

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

If I ask you what is going to be obtained first, the user information or the contact information – assuming no exceptions ...

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