Interview Question


Country: United States




Comment hidden because of low score. Click to expand.
1
of 1 vote

The concurrentHashMap iterators are not fail-fast in the sense that they do not throw a ConcurrentModificationException. They also do not guarantee that once the iterator is created it will list/show all elements that are added after its creation. The iterators do however guarantee that any updates or removal of items will be reflected correctly in their behaviour. They also guarantee that no element will be returned more than once while traversal. which is a big draw back
hence in nut shell The no-synchronized Iterator is a major drawback i know for ConcurrentHashMap .

- manish April 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The implementation of concurrency in the hashmap adds overhead to its operations, so in cases where there is little contention for the map (and hence little time spent waiting on any locks on the map to be released) you may be better off with a regular hashmap since any uncontested lock checking on that map will be very fast.

Also ConcurrentHashmaps cannot contain null keys or values, which may be problematic in some applications.

- Anonymous April 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Disadvantages are :
You can't lock the whole map to find the size of the map.
Iterators are weakly consistent.

- OTR December 02, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More