You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This program does not necessarily output ten rows. What happens is: it starts say("world") in a background goroutine, executes say("hello"), and then exits. In practice, because the sleep is so long, the two likely scenarios are:
say("world") completing before say("hello"), in which case you get 10 lines, or
say("hello") completing before the final loop of say("world"), in which case you get 9 lines.
(On a machine starved for CPU you could see fewer "world" lines, but you would have to construct such a case.)
mikioh
changed the title
Different behavior in go1.5beta2 on MacOS and Linux
runtime: Different behavior of go routines in go1.5beta2 on MacOS and Linux
Jul 24, 2015
The example is taken from the "A Tour of Go": https://tour.golang.org/concurrency/1
Obviously, program output should have 10 rows: 5 for "hello" and 5 for "world".
But we have on:
Linux output (9 rows):
MacOS X output (10 rows):
Can anyone explain - why?
Linux
uname -a
:MacOS X
uname -a
:Source code from tour:
The text was updated successfully, but these errors were encountered: