Junior — Senior
Competitive recording in slice and the role of GOMAXPROCS
livecode
Task condition
Determine what value will be printed by the program when run on a single-core system and on a multi-core system. Note that multiple goroutines are simultaneously modifying the same slice element, and the Go scheduler distributes their execution depending on the current value of GOMAXPROCS.
func main() {
data := make([]string, 0)
for i := 0; i < 10; i++ {
data = append(data, string(i))
}
go func() { data[1] = "Не знаю" }()
go func() { data[1] = "Не 1" }()
go func() { data[1] = "2" }()
time.Sleep(400 * time.Millisecond)
fmt.Println(data[1])
}