Hi folks,

somwhere on my golang journey ("don't k now where and when") I was teached 
that mutexes are very expensive and we should prefer to communicate over 
channels instead of working with mutexes.
I trusted it until today. I explained it to our aprentice based on my 
knowledge and he asked me  if i can show him the performance difference. 

Therefore I wrote this little demo with the expectation that the channel 
solution will beat the mutex one and was really surprised when I saw that 
the mutex based solution beats the channels one most of the time by factor 
2.

https://play.golang.org/p/Kf9VBSoTLcU

What am I missing here or is it not true anymore that mutexes are so 
expensive that we should prefer Communicating over Sharing.


kind regards


Reinhard Lüdiger

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to