1.

What happens if two threads simultaneously modify TreeSet?(a) ConcurrentModificationException is thrown(b) Both threads can perform action successfully(c) FailFastException is thrown(d) IteratorModificationException is thrownThe question was posed to me in homework.Query is from Data Structures-Set in portion java.util – The Collections Framework of Java

Answer»

Correct choice is (a) ConcurrentModificationException is thrown

Best explanation: TreeSet PROVIDES fail-fast ITERATOR. Hence when concurrently MODIFYING TreeSet it throws ConcurrentModificationException.



Discussion

No Comment Found

Related InterviewSolutions