Questions tagged [data-race]

A data race occurs when:

  • two or more threads in a single process access the same memory location concurrently, and

  • at least one of the accesses is for writing, and

  • the threads are not using any exclusive locks to control their accesses to that memory.

When these three conditions hold, the order of accesses is non-deterministic, and the computation may give different results from run to run depending on that order. Some data-races may be benign (for example, when the memory access is used for a busy-wait), but many data-races are bugs in the program.

(source: https://docs.oracle.com/cd/E19205-01/820-0619/geojs/index.html)

108 questions
-2
votes
1 answer

Structure assignment in Go is it data race?

I read this post about data races. And I understand, that access to interface variable need to be sync. But what about access to struct? For example we have this code: package main import ( "fmt" ) type s struct { field0 uint8 field1…
user11968497
-3
votes
2 answers

data-race, two goroutines plus same val

consider below code, in my opinon, val will between 100 and 200, but it's always 200 var val = 0 func main() { num := runtime.NumCPU() fmt.Println("使用cpu数量", num) go add("A") go add("B") time.Sleep(1 * time.Second) …
space
  • 27
  • 4
1 2 3 4 5 6 7
8