|
Dave Cheney |
at Nov 13, 2013 at 9:37 am
|
⇧ |
| |
In the playground, the results are always cached.
If you want to see this race, use the race detector.
lucky(~/src) % go run -race race.go
==================
WARNING: DATA RACE
Write by goroutine 4:
main.func·002()
/home/dfc/src/race.go:10 +0x65
Previous write by goroutine 3:
main.func·001()
/home/dfc/src/race.go:9 +0x5f
Goroutine 4 (running) created at:
main.main()
/home/dfc/src/race.go:10 +0x15f
Goroutine 3 (finished) created at:
main.main()
/home/dfc/src/race.go:9 +0xf0
==================
{3 4}
Found 1 data race(s)
exit status 66
lucky(~/src) % cat race.go
package main
import "fmt"
func main() {
done := make(chan bool)
type T struct{ a, b string }
var x T
go func() { x = T{"1", "2"} }()
go func() { x = T{"3", "4"}; done <- true }()
<-done
fmt.Println(x)
}
On Wed, Nov 13, 2013 at 8:15 PM, wrote:Thanks. How can I get some randomness - I always get {3, 4} and map[1:1
2:2] ?
W dniu środa, 13 listopada 2013 10:06:13 UTC+1 użytkownik Dave Cheney
napisał:
yes, and it probably will, concurrent map modification is very likely
to corrupt the internal structures of the Go hashmap type.
--
You received this message because you are subscribed to the Google
Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to golang-nuts...@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out. --
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.