i'm reading a book about concurrency, and was doing some baby steps so i'm trying to manage a variable changes to be locked when a process starts and freed when it ends
this is the initial code https://play.golang.org/p/qGraa8yQEc and this is my solution https://play.golang.org/p/wC9tcbpVjf my question is, when i run the last code through the race detector i get this ================== WARNING: DATA RACE Read at 0x0000005870c4 by goroutine 7: main.divide() /home/marwan/go/src/sync/main.go:24 +0x41 Previous write at 0x0000005870c4 by goroutine 6: main.increase() /home/marwan/go/src/sync/main.go:17 +0x9d Goroutine 7 (running) created at: main.main() /home/marwan/go/src/sync/main.go:36 +0x70 Goroutine 6 (running) created at: main.main() /home/marwan/go/src/sync/main.go:35 +0x4f ================== ================== WARNING: DATA RACE Write at 0x000000587138 by goroutine 10: main.divide() /home/marwan/go/src/sync/main.go:30 +0x7d Previous write at 0x000000587138 by goroutine 6: main.increase() /home/marwan/go/src/sync/main.go:19 +0xc4 Goroutine 10 (running) created at: main.divide() /home/marwan/go/src/sync/main.go:26 +0x113 Goroutine 6 (finished) created at: main.main() /home/marwan/go/src/sync/main.go:35 +0x4f ================== 1 Found 2 data race(s) while it actually works as it should be ( the first invoked goruotines lock the variable and even if it takes time, the other goroutines can't access the variable) so is there any problem here? -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.