Re: [go-nuts] Does data race with only multiple goroutine parallel i=1 have an impact on the execution results?

2024-07-06 Thread 'qiu laidongfeng2' via golang-nuts
encounter that it is always output 1, so I ask. 在2024年7月6日星期六 UTC+8 22:20:57 写道: > On Sat, Jul 6, 2024 at 7:04 AM 'qiu laidongfeng2' via golang-nuts > wrote: > > > > Does data race in this program affect execution results? > > In amd64, it always output1. > >

[go-nuts] Does data race with only multiple goroutine parallel i=1 have an impact on the execution results?

2024-07-06 Thread 'qiu laidongfeng2' via golang-nuts
Does data race in this program affect execution results? In amd64, it always output1. ```go package main import "sync" func main() { i := 0 var wg sync.WaitGroup for range 100 { wg.Add(1) go func() { defer wg.Done() i = 1 }() } wg.Wait() println(i) } ``` -- You received this message becaus