[go-nuts] Re: parallel array processing question

2018-04-20 Thread Ankit Gupta
There could have been a data race in your code with the usage of allMax variable which is updated and checked by multiple goroutines. But you are saved by the use of mutex. All shared variables, in general, are subject to data races when there is a write involved. The local variables you create

[go-nuts] Re: parallel array processing question

2018-04-19 Thread Stefan Nilsson
Reading only is safe, but you will have a data race if two goroutines access the same variable concurrently and at least one of the accesses is a write. Here is an article that gives some rules of thumb on how to efficiently schedule parallel computation on separate CPUs: http://yourbasic.org/g

[go-nuts] Re: parallel array processing question

2018-04-19 Thread Egon
When you have such questions, then run your code with the race detector. https://golang.org/doc/articles/race_detector.html Otherwise, you are only reading from the slice, there is no racing possible. Also, your max function looks very weird and has a small bug: https://play.golang.org/p/8K-0ze3