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 8387673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:16:42+00:00 2026-06-09T18:16:42+00:00

From the Javadoc I know ConcurrentHashMap.replace is atomic, but what about ConcurrentHashMap.put ? I

  • 0

From the Javadoc I know ConcurrentHashMap.replace is atomic, but what about ConcurrentHashMap.put? I see they are differently implemented in the source code but I’m not able to figure out their differences. Any gurus to give some guidelines about how to use these two methods?

  • 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-09T18:16:43+00:00Added an answer on June 9, 2026 at 6:16 pm

    They are functionally different. replace only stores the key-value pair if there already was a value stored under the specified key. The API documentation of replace explains it:

    Replaces the entry for a key only if currently mapped to some value. This is equivalent to

    if (map.containsKey(key)) {
        return map.put(key, value);
    } else return null;
    

    except that the action is performed atomically.

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

Sidebar

Related Questions

I would like to generate javadoc but excluding deprecated methods from it. I know
I am writing a tool to scrape Javadoc from pre-existing Java source files and
In Java, I need to know what is the bind operation: ServerSocket.bind() From Javadoc:
I'm trying to implement the sample code to this article from 2002 (I know..),
From the JavaDoc, the EXTRA_STREAM parameter when launching an intent needs to be an
I am generating the Javadoc from my project with gradle, and I want to
Possible Duplicate: When do you use Java’s @Override annotation and why? From the javadoc
I find Fragment#setRetainInstance(true) confusing. Here is the Javadoc, extracted from the Android Developer API
The code pasted below was taken from Javadocs on HttpURLConnection . I get the
I want to link from my project Trac page to my javadoc index.html file,

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.