Closing-channel.go result ?? #101
andradei
commented
Jun 27, 2015
It would always be the same. Even though there is a part of the code that is run on a separate thread, it runs in sync with the main thread.
Bruce-sz
commented
Jul 21, 2015
I carefully check the code, and the "GitHub" code is the same, but why I always get the following results:
[ go run closechan.go | done: 307.238771ms ]
sent job 1
sent job 2
sent job 3
sent all jobs
received job 1
received job 2
received job 3
received all jobs
pawanrawal
commented
Apr 3, 2016
I think this is because the channel is buffered, hence all jobs are sent first and then received. IMHO , its a bug @mmcgrana
andradei
commented
Apr 4, 2016
Also, sometimes the execution of so little code is "too fast" and the result always comes out in order as though it didn't run on separate threads. But yeah, it could also be a bug.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the result of gobyexample/example/closing-channels/closing-channels.go in your website !
$ go run closing-channels.go
sent job 1
received job 1
sent job 2
received job 2
sent job 3
received job 3
sent all jobs
received all jobs
I want to ask whether the result is always the same , or different at runtime !