The problem is that I have this method createNode()
that creates a node in a tree, and then if it's a leave node it adds it into an ArrayList<Tree> treeLeaves
, and I make the call of this method while browsing the treeLeaves
ArrayList like this :
Iterator<Tree> iter = treeLeaves.iterator();
while (iter.hasNext()) {
iter.next().createNode();
}
Or like this :
For (Tree cursor : treeLeaves) {
cursor.createNode();
}
But I keep having this exception :
Exception in thread "main" java.util.ConcurrentModificationException
Even when put the codes below in snychronized(treeLeaves){}
bloc.
P.S: I don't know if this is usefull or not but; it's an n-Tree.