Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:56:42+00:00 2026-06-04T15:56:42+00:00

The ConcurrentHashMap provides thread-safe but the docs state: However, even though all operations are

  • 0

The ConcurrentHashMap provides thread-safe but the docs state:

” However, even though all operations are thread-safe, retrieval operations do not entail locking”

So from this I understand that getting or setting a key and value are thread-safe, but modifying the actual VALUE of any given key isn’t (by value I actaully mean the value or state of that object).

I’m just confused on how this works, at the moment I think things work like this.

The ConcurrentHashMap only gaurantees the key’s are thread-safe in terms setting/getting them. But the object you put inside the map has to gaurd for concurrency by itself.

Is this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:56:44+00:00Added an answer on June 4, 2026 at 3:56 pm

    But the object you put inside the map has to gaurd for concurrency by itself.

    Your understanding is correct.

    From the documentation:

    However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access.

    What the above is also saying is that there is no built-in mechanism for automatic locking of the hash map while the reading takes place. In particular, this means that get() operations can overlap with concurrent modifications performed by other threads.

    The document goes on to explain the concurrency semantics:

    Retrieval operations (including get) generally do not block, so may overlap with update operations (including put and remove). Retrievals reflect the results of the most recently completed update operations holding upon their onset. For aggregate operations such as putAll and clear, concurrent retrievals may reflect insertion or removal of only some entries. Similarly, Iterators and Enumerations return elements reflecting the state of the hash table at some point at or since the creation of the iterator/enumeration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The JDK provides a set of thread-safe classes like ConcurrentHashMap, ConcurrentLinkedQueue and AtomicInteger. Are
I have the following code. Will it be thread safe even if the set
If I'm using ConcurrentHashMap (where the put is thread safe) , and I supply
Is this class thread-safe? class Counter { private ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<String,
if(concurrentHashMap.containKey(key)) { // oops, v has been removed in another thread right after current
I have a class like the below and am wondering, will this be thread-safe
ConcurrentHashMap is fully interoperable with Hashtable in programs that rely on its thread safety
I want to make my class thread-safe without large overhead. The instances will be
There seems to be a lot of different implementations and ways to generate thread-safe
I have a variable: ConcurrentHashMap<String, List<AnObjectType>> mapOfList; The List as I understand is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.