You can download Java (JDK5 or later) and have a look at class 
ConcurrentHashMap. This will give you a blueprint about how this can be 
implemented using segments. After segment lookup for a given hash code only 
the segment needs to be locked, but not any more the entire map. Note, that 
you still have to lock the entire map when you do traversals. So it is 
recommend to avoid traversals where possible.

Am Montag, 13. März 2017 07:39:59 UTC+1 schrieb Albert Tedja:
>
> Hello,
>
> I know map itself isn't threadsafe, but I am just wondering how threadsafe 
> it is if you can be absolutely sure that each goroutine accesses a 
> different key in the map.
> Say, goroutine 1 accesses mymap["1"]
> and goroutine 2 accesses mymap["2"] and so on.
>
> Thank you in advance.
>

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

Reply via email to