Go implements the monitor pattern thanks to the
sync package and the
sync.Cond structure. The monitor pattern allows our goroutines to wait for a specific condition while entering in a sleeping mode without blocking our execution or consuming resources.
Condition variable in action
Let’s start with an example of this pattern in order to see the advantages it could bring. I will use…