What is the Difference between HashMap and Concurrent HashMap?
4. In multiple threaded environment HashMap is usually faster than ConcurrentHashMap . As only single thread can access the certain portion of the Map and thus reducing the performance, While in HashMap any number of threads can access the code at the same time.
What are the methods of Objects class?
- ConcurrentHashMap is thread-safe that is the code can be accessed by single thread at a time .
while HashMap is not thread-safe - ConcurrentHashMap synchronizes or locks on the certain portion of the Map . To optimize the performance of ConcurrentHashMap , Map is divided into different partitions depending upon the Concurrency level . So that we do not need to synchronize the whole Map Object.
3. ConcurrentHashMap does not allow NULL values . So the key can not be null in
ConcurrentHashMap .While In HashMap there can only be one null key .4. In multiple threaded environment HashMap is usually faster than ConcurrentHashMap . As only single thread can access the certain portion of the Map and thus reducing the performance, While in HashMap any number of threads can access the code at the same time.
What are the methods of Objects class?
- clone()
- equals(Object)
- finalize()
- getClass()
- hashCode()
- notify()
- notifyAll()
- toString()
- wait()
- wait(long)
- wait(long, int)
What is the marker interface?
If interface wont contain any methods, by implementing that interface if our object will get ability such type of interfaces are called marker interface.
Exmaples;
- java.lang.Cloneable
- java.io.Serializable
- java.util.EventListener. etc
No comments:
Post a Comment