I'm currently working on a game that is multi-threaded, there is one thread running the updates for the game and one thread repainting the panel that the game is being played on. After editing some code that was responsible for an enemy firing projectiles at the player i noticed that i was getting a ConcurrentModificationException from the Iterator that was iterating through all the entities and updating them. I isolated the problem to this statement here:
getMyBounds2D().getCenterY();
Because when I change the the statement to:
getMyBounds2D().getY();
the Exception is no longer thrown from the updating Iterator. the method getMyBounds2D() just returns a Rectangle2D that is representative of the bounding box of the entity, is there anyone that could explain why changing the statement above causes a CME and how to fix this issue?