Why this problem is coming?
Concurrentmodificationexception is may thrown by methods I mean one thread to modify a collection while another thread is iterating over it.
For example if you adding some elements to collections at the same time some other thread is removing some elements from the collections means it might throw Concurrentmodificationexception.
How to solve it?
There are two ways available for this problem.
1. Using synchronized method(need to consider performance issue).
2. Using below classes.
ConcurrentHashMap
CopyOnWriteArrayList
0 comments:
Post a Comment