Is ConcurrentHashMap.get() guaranteed to see a previous ConcurrentHashMap.put() by different thread?

Some good answers here, but as far as I can tell no-one has actually provided a canonical answer to the question asked: “Is ConcurrentHashMap.get() guaranteed to see a previous ConcurrentHashMap.put() by different thread”. Those that have said yes haven’t provided a source.

So: yes, it is guaranteed. Source (see the section ‘Memory Consistency Properties’):

Actions in a thread prior to placing an object into any concurrent collection happen-before actions subsequent to the access or removal of that element from the collection in another thread.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)