Quick: What fundamental principle do all of the following have
in common? - Two children drawing with crayons. - Three
customers at Starbucks adding cream to their coffee. - Four
processes running on a CPU core. - Five threads updating an
object protected by a mutex. - Six threads running on different
processors updating the same lock-free queue. - Seven modules
using the same reference-counted shared object. Answer: In each
case, multiple users share a resource that requires coordination
because not everyone can use it simultaneously and such sharing
is the root cause of all resulting contention that will degrade
everyone's performance. (Note: The only kind of shared resource
that doesn't create contention is one that inherently requires
no synchronization because all users can use it simultaneously
without restriction, which means it doesn't fall into the
description above. For example, an immutable object can have its
unchanging bits be read by any number of threads or processors
at any time without synchr