On Thu, Jan 19, 2017 at 9:19 PM, xiaohai dai <seafoo...@gmail.com> wrote:
>
> Thanks for your reply.
> However, I don't think reading and writing w.last concurrently will lead to
> data race.
> In my opinion, concurrent writing to w.last may lead to data race, but
> reading and writing concurrently here may not.
> Look forward to your reply again.

But that is what a data race is: reading a value in one goroutine
while writing it in a different goroutine (writing in two different
goroutines is also a data race).  See https://golang.org/ref/mem .

Ian

> 在 2017年1月20日星期五 UTC+8下午1:03:07,Ian Lance Taylor写道:
>>
>> On Thu, Jan 19, 2017 at 7:05 PM, xiaohai dai <seaf...@gmail.com> wrote:
>> > I am reading "Data Race Detector"  from Godoc.
>> > However, I'm confused by the example: Primitive unprotected variable
>> > displayed in the post. I don't know why this example could lead to data
>> > race.
>>
>> The assumption is that there is some other code, not shown, that calls
>> the KeepAlive method.  Setting the w.last field in KeepAlive races
>> with reading it in the goroutine started in Start.
>>
>> Ian
>
> --
> 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.

-- 
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.

Reply via email to