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?