Distributed work without channels

In order to distribute the work equally among the cashiers, we need to know the amount of orders we will get beforehand and ensure that the work each cashier receives is within his/her limit. This is not the most practical solution, because it would fail in a real-world scenario where we would need to keep track of how many orders each cashier has processed and divert the remaining orders to the other cashiers. However, before we look at the correct way to solve it, let's take time to better understand the problem of uncontrolled parallelism and try to solve it. The following code attempts to solve it in a naïve manner, which should provide us with a good start:

// wochan.go package main import ( "fmt" "sync" ...

Get Distributed Computing with Go 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.