O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Goroutines aren't predictable

In this chapter, we started by looking at how Go enables us to write code that is concurrent and, to an extent, parallel. Then we followed up with a discussion on how Go schedules goroutines over machines and processors. It is possible that we might be able to reason how the goroutines are going to be distributed over machines and processors, which in turn might let us write non-standard or hacky Go code.

Consider the code from the Parallelism section, where we tried to simulate listening to music while writing a few emails. Here is the output of the code for quick reference:

Done writing mail #3. 19:32:57
Listening... 19:32:57
Listening... 19:32:57
Done writing mail #1. 19:32:57
Listening... 19:32:57
Listening... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required