-
What happens if two threads simultaneously modify TreeSet?
-
- IteratorModificationException is thrown
- FailFastException is thrown
- Both threads can perform action successfully
- ConcurrentModificationException is thrown
- None of these
Correct Option: D
TreeSet provides fail-fast iterator. Hence when concurrently modifying TreeSet it throws ConcurrentModificationException.