Monday, 25 April 2016

When ConcurrentModificationException occurs ?


ConcurrentModificationException 
is a unchecked (runtime) exception that 
may be thrown :

 1. When concurrent modification of an object detected while such modification is not permissible
 ExampleOne thread to modify a Collection while another thread is iterating over it)

2. If a thread modifies a collection directly while it is iterating over the collection with a Fail-fast iterator

Note : ConcurrentModificationException should be used only to detect bugs.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.