* Yuan Ting <
yuan...@ict.ac.cn> [200301 23:50]:
I think the other responses missed the obvious here (or at least chose
more elaborate, though correct, explanations). This is a variable
assignment in one goroutine concurrent with a variable reference in
another. It is exactly the same (from the point of view of whether it
is a race or not) as this:
var a = 17
go func() {
a = 987654
}()
go func() {
fmt.Println(a)
}
In the second goroutine, the variable a might have the value 17, it
might have the value 987654, and it might have garbage that is neither
of these. This is a race condition, and it is also true of the channel
code above.
One of the other responses very correctly said that a race does not
imply that the code could panic. The integer code above will never
panic, even on architectures where a write of an integer to memory
concurrent with a read from that memory can possibly allow the read to
return partially written data. However, the above code is clearly a
race condition.
...Marvin