How to debug ConcurrentModificationException?

Posted by Dani on Stack Overflow See other posts from Stack Overflow or by Dani
Published on 2009-05-08T14:49:30Z Indexed on 2010/06/12 23:12 UTC
Read the original article Hit count: 172

I encountered ConcurrentModificationException and by looking at it I can't see the reason why it's happening; the area throwing the exception and all the places modifying the collection are surrounded by

synchronized (this.locks.get(id)) {
  ...
} // locks is a HashMap<String, Object>;

I tried to catch the the pesky thread but all I could nail (by setting a breakpoint in the exception) is that the throwing thread owns the monitor while the other thread (there are two threads in the program) sleeps.


How should I proceed? What do you usually do when you encounter similar threading issues?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading