July 2018
Intermediate to advanced
266 pages
7h 11m
English
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, ...