I have a question about concurrency in GoLang. Here is a sample code in GoLang
package main
import(
"fmt"
"time"
)
var m int
func add(i int){
m++
}
func main() {
m = 0
for i:=0;i<100;i++{
go add(i)
}
time.Sleep(time.Millisecond * 1000)
fmt.Println(m)
}
When I execute it I always have the same result 100, even if I execute it several times.
If I do the same code in C (without mutex), sometimes I have different results.
And my question, I would like to know if GoLang implicitly manages access to a shared variable using an internal mechanism ?
Thank you.