3 ms·
When I run the second example on play.golang.org, the output I get is: This program will get 10 IDs from the id channel, print them and terminate 0a90
by brown9-2 14y ago
When I run the second example on play.golang.org, the output I get is:
This program will get 10 IDs from the id channel, print them and terminate
0a90333b6c0f5519b6e5f7ea2d541fb1793b957d
58 bytes written
af2f87580bb3562b58f2ad076e25f76ebf8fec75
0 bytes written
4491029b704d192be5a31eb0c35dfe516274d173
58 bytes written
d97a9080d01e9a8a11d0152d3df34f1c90f5cf16
0 bytes written
130c9fda35c98c7e8922d6ea24bb873838cfdcbd
58 bytes written
0e385bcc65efb6bac8ced67639c32b374d31ae57
0 bytes written
550413e7244dd40cf3df52634bb341dc166708b2
58 bytes written
49cfddab6ff9123ad237f03176927329349e186b
0 bytes written
12abf2ab19e52065b3f7367a57f6f8ecd4968b44
58 bytes written
0755254307f5f9b90829381fa797b5f26081cd5f
0 bytes written
Why does the count alternate between 58 and 0?
- deleted 14y ago[deleted]
- jgrahamc 14y agoThat's left as an exercise for the reader. Look at the channel synchronization and follow the code for both routines (the main and the goroutine). I'll admit in this case that it looks pretty deterministic, but in other cases it could be a different pattern.
- minikomi 14y agoHave a look at this, if it makes it any easier! http://play.golang.org/p/2s7S3BM6Oe http://play.golang.org/p/2s7S3BM6Oe