Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Briefly explain concurrentHashMap. How is it better than HashMap and HashTable in terms of concurrency?

Pragya Keshap answered on February 22, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Implementation of LinkedHashMap Class in Java map
  • Java Create a ConcurrentHashMap
  • concurrenthashmap in java
  • Hash map, Hash set and Hash Table difference
  • What are the main differences between HashMap and ConcurrentHashMap in Java?
  • What are the major differences between a HashSet and a HashMap?
  • hash table hashing method
  • Java Access ConcurrentHashMap Elements
  • hash map
  • Why String is popular HashMap key in Java?
  • Java Creating ConcurrentHashMap from Other Maps
  • concurrency level in concurrenthashmap
  • Internal Working of Concurrent HashMap
  • What is the default size of load factor in a HashMap collection in Java?
  • What is the scenario to use ConcurrentHashMap in Java?
  • Is it possible to replace Hashtable with ConcurrentHashMap in Java?

  • Briefly explain concurrentHashMap. How is it better than HashMap and HashTable in terms of concurrency?

    0

    Concurrent Hashmap is a class that was introduced in jdk1.5. Concurrent hash map applies locks only at bucket level called fragment while adding or updating the map. So, a concurrent hash map allows concurrent read and write operations to the map.

    HashTable is a thread-safe legacy class introduced in the Jdk1.1. It is a base implementation of Map interface. It doesn't allow null keys and values. It is synchronized in nature so two different threads can’t access simultaneously. Hashtable does not maintain any order.

    Sr. No.

    Key

    HashTable

    ConcurrentHashMap

    1

    Basic

    HashTable is a thread-safe legacy class introduced in the Jdk1.1

    ConcurrentHashmap is a class that was introduced in jdk1.5

    2

    Locking

    It applies lock on the entire collection

    ConcurrentHashMap apply locks only at bucket level called fragment while adding or updating the map

    3

    Performance

    It is slower than ConcurrentHashMap

    It is better than HashTable

    4.

    Null

    It doesn't allow null key and value

    It allows null key and value 


    https://www.tutorialspoint.com/difference-between-hashtable-and-concurrenthashmap-in-java

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 22 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.