mmcgrana / gobyexample

Go by Example
https://gobyexample.com
7.16k stars 1.26k forks source link

Update closing-channels.sh #538

Closed Shikhar21121999 closed 3 months ago

Shikhar21121999 commented 3 months ago

Updated results on running the code in go go version go1.22.0 linux/amd64

Explanation: Since jobs being a buffered channel of capacity 5, when we are sending values 1 to 3 to job channel on line 22 to 25. The send to job channel on line 23 is non blocking. Hence Sent job takes place immediately, while anonymous go routine on line 9 gets scheduled and executed in background after some delay, and it is during that time when receiving from job channel takes place. Also to mention receiving is also non-blocking. Functioning of done channel works the same as illustrated in the example.