Nguyễn Trần Mai Trang
New member
What is thread-safety how do you achieve it?
Answer
Unlike their synchronized counterparts, concurrent collections achieve thread-safety
by dividing their data into segments
. In a ConcurrentHashMap, for instance, several threads can acquire locks on different map segments, so multiple threads can access the Map at the same time.
Answer
Unlike their synchronized counterparts, concurrent collections achieve thread-safety
by dividing their data into segments
. In a ConcurrentHashMap, for instance, several threads can acquire locks on different map segments, so multiple threads can access the Map at the same time.