public Damage getMonsterTouchDamage(Rectangle r, int x) { Damage damage = null; Monster monster = null; try { for (String key : monsters.keySet()) { monster = (Monster) monsters.get(key); damage = monster.getMonsterTouchDamage(r, x); if (damage != null) { break; } } } catch (ConcurrentModificationException concEx) { // another thread was trying to modify monsters while iterating // we'll continue and the new item can be grabbed on the next update } return damage; }