I think that is a bit unclear - even if they access different elements, if they 
ever access the same element even at different times , you need 
synchronization- it’s not only if the access the same element “concurrently”. 

>> On Nov 8, 2019, at 2:54 AM, Volker Dobler <dr.volker.dob...@gmail.com> wrote:
> 
>> On Friday, 8 November 2019 05:47:03 UTC+1, Kasun Vithanage wrote:
>> What is the best approach?
> 
> There is no single "best approach".
> 
> If two goroutines A and B access two different indices iA and iB you
> do not need any synchronisation between them. If iA==iB you need
> to protect reads from concurrent writes.
> 
> If you have far more reads than writes: Use a RWMutex, otherwise
> a Mutex probably is fine. The trick here: Experiment and measure.
> 
> You can synchronise on the Bar-level or on the level of individual Foos.
> Or you can group lets say N Foos together and synchronise on the
> level of these groups. The trick here: Experiment and measure.
> 
> So it boils down to: What is your access pattern? Make several
> experiments which simulate this pattern and measure. Then decide
> on "the best".
> 
> V.
>  
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/e8fd2954-6b46-4337-8564-16e3f771098d%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/F3D828C7-8DC4-4887-8BA1-9B8115E7690A%40ix.netcom.com.

Reply via email to