filmov
tv
Concurrent Collection Interview questions and Answers for experienced and freshers | Code Decode
Показать описание
This video contains Concurrent Collection Interview questions and Answers for experienced and freshers Candidates.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
Course Description Video :
Concurrent collection is a very important topic in terms of collection interview questions and answers for experienced and answers
Q) Difference between Synchronized Collection and Concurrent Collection?
Both Synchronized and Concurrent Collection classes provide thread-safety
The differences between them comes in performance, scalability and how they achieve thread-safety.
Synchronized collections like synchronized HashMap are much slower than their concurrent counterparts e.g. ConcurrentHashMap, Main reason for this slowness is locking;
What is the need of concurrent collection
Traditional collections are not thread safe. only few classes like Vector, HashTable are thread safe.
Collections provide some methods like synchronizedList, synchronizedMap, synchronizedSet those provide thread safety but problem is they capture lock on complete collection even for reading that decreases performance.
In traditional collection if one thread iterates and other tries to modify structural change then ConcurrentModificationException is thrown.
Give few concurrent collections classes ?
ConcurrentHashMap
CopyOnWriteArrayList
CopyOnWriteArraySet
Why performance of ConcurrentHashMap is better than HashTable and synchronizedMap ?
In HashTable and synchronizedMap lock is acquired on complete collection so only single thread can capture lock at a time while in ConcurrentHashMap lock is acquired on bucket level so at a time multiple thread can capture lock on different different bucket.
Promotional Links
Code Decode Playlists
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
--------------------------------------------------------------------------------------------------------------------------------------
#javacollectioninterviewquestion #topjavacollectioninterveiwquestion #javainterviewquestion #codedecode
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
Course Description Video :
Concurrent collection is a very important topic in terms of collection interview questions and answers for experienced and answers
Q) Difference between Synchronized Collection and Concurrent Collection?
Both Synchronized and Concurrent Collection classes provide thread-safety
The differences between them comes in performance, scalability and how they achieve thread-safety.
Synchronized collections like synchronized HashMap are much slower than their concurrent counterparts e.g. ConcurrentHashMap, Main reason for this slowness is locking;
What is the need of concurrent collection
Traditional collections are not thread safe. only few classes like Vector, HashTable are thread safe.
Collections provide some methods like synchronizedList, synchronizedMap, synchronizedSet those provide thread safety but problem is they capture lock on complete collection even for reading that decreases performance.
In traditional collection if one thread iterates and other tries to modify structural change then ConcurrentModificationException is thrown.
Give few concurrent collections classes ?
ConcurrentHashMap
CopyOnWriteArrayList
CopyOnWriteArraySet
Why performance of ConcurrentHashMap is better than HashTable and synchronizedMap ?
In HashTable and synchronizedMap lock is acquired on complete collection so only single thread can capture lock at a time while in ConcurrentHashMap lock is acquired on bucket level so at a time multiple thread can capture lock on different different bucket.
Promotional Links
Code Decode Playlists
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
--------------------------------------------------------------------------------------------------------------------------------------
#javacollectioninterviewquestion #topjavacollectioninterveiwquestion #javainterviewquestion #codedecode
Комментарии