Post a Job  |   Ask a Question?   |   Already registered? login or register
26/04/2016 11:54 PM

interview question

What is difference between fail-fast and fail-safe Iterator in Java?
Spam    2 Comments

27/04/2016 00:09:26
Fail fast iterator:- =========== Normally in our traditional collection like List,Set,Map implementation class when one thread trying to iterating then at same time another thread try to modify underlaying ds then we will get ConcurrentModificationException so in this sitution we can say it is fail-fast Fail safe: ======= Here if one thread trying to iterate and another thread also try to modify something also it will not affect our underlaying ds..which is fail safe to achive fail safe in concurrent pkg sunpeople interduce 3 synchronized class 1.CopyOnWriteArrayList 2.CopyOnWriteSet 3.ConcurrentHashMap

27/04/2016 15:35:19
Pour 5 liters from the 8-liter to the 5-liter bowl. Pour 3 liters from the 5-liter to the 3-liter bowl, then pour those 3 liters back to the 8-liter bowl (the 8-liter bowl now has 6 liters). Pour the remaining 2 liters from the 5-liter over to the 3-liter bowl, the bowls now contain 6, 0 and 2 liters each. Now, pour 5 liters from the 8-liter to the 5-liter bowl (the 8-liter bowl now has 1 liter) Pour from the 5-liter to the 3-liter bowl until it is full (exactly one liter). There should now be 4 liters left in the 5-liter bowl, Pour the 3 liters from the 3-liter to the 8-liter bowl (and now the 8-liter bowl has 4 liters)

Languages :