8 Concurrency: Foundations

This chapter covers

  • Understanding concurrency and parallelism
  • Why concurrency isn’t always faster
  • The impacts of CPU-bound and I/O-bound workloads
  • Using channels vs. mutexes
  • Understanding the differences between data races and race conditions
  • Working with Go contexts

In recent decades, CPU vendors have stopped focusing only on clock speed. Instead, modern CPUs are designed with multiple cores and hyperthreading (multiple logical cores on the same physical core). Therefore, to leverage these architectures, concurrency has become critical for software developers. Even though Go provides simple primitives, this doesn’t necessarily mean that writing concurrent code has become easy. This chapter discusses fundamental concepts ...

Get 100 Go Mistakes and How to Avoid Them now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.