Original post

Hi. I’ve been enthusiast for a few months. Lately I wanted to consolidate my knowledge of concurrency. The following excerpt is from the book “Concurrency in ” (by O’Reilly):


It works as it should (I suppose).
However if I add a few fmt.Println or another function – it deadlocks. :


The use of the “useless” function causes deadlock 1/~10k application runs. On the other hand, if I comment out the useless function and uncomment fmt.Println – deadlock occurs much more often.

Can somebody explain why is it happening?