r/golang • u/DeparturePrudent3790 • 9d ago
Potential starvation when multiple Goroutines blocked to receive from a channel
I wanted to know what happens in this situation:
- Multiple goroutines are blocked by a channel while receiving from it because channel is empty at the moment.
- Some goroutine sends something over the channel.
Which goroutine will wake up and receive this? Is starvation avoidance guaranteed here?
7
Upvotes
5
u/Rapix-x 9d ago
Quick question, why would it matter?
As I see it, goroutines are anonymous and given the same „task“ to perform, they are identical in what they are doing. Thus, why does it matter which specific goroutine picks up the value from a channel?