On Tuesday, 16 May 2017 08:10:56 UTC+3, Yan Tang wrote:
>
> Hi,
>
> I am aware of golang map is not safe for concurrent access, especially 
> when there is at least one writer.
>
> However, I want to know that if the map has been pre-populated, and 
> different coroutines access (read/write) different key/value pair, is it 
> safe to do so?  There is no deletion or adding keys after the 
> initialization.
>
> I think it should be safe (having been doing this in C++ quite frequently) 
> but just want to double check. 
>

In Go use `-race` to test safety. (https://blog.golang.org/race-detector)
In C++ use `thread-sanitizer` to test safety. 
(https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual)

Given the description, it's not safe in Go... and AFAIK, it isn't safe in 
C++ either.

See 
https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
 
for more information. 

+ Egon

-- 
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