java - which thread will get concurrentModificationException with two threads -


i have 2 thread 1 thread adding,removing in arraylist , thread iterating iterator arraylist. thread concurrentmodificationexcetion;

the thread iterator. it's iterator detects (on best effort basis) underlying collection has changed, , throws exception.

of course common situation concurrentmodificationexception when using single thread both iterates collection , attempts modify it:

list<string> foo = ... ; for(string s : foo) {  // exception thrown here after 1st iteration     foo.add("let's throw exception!"); } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -