Java concurrent modification exception when removing items from list
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5145135/java-util-concurrentmodificationexception-on-arraylist">java.util.ConcurrentModificationException on ArrayList</a>  </p>
</blockquote>



<p>I am trying to remove items from a list inside a thread. I am getting the  <code>ConcurrentModificationException</code>. I read from this <a href="http://stackoverflow.com/questions/8090398/java-concurrent-modification-exception">link</a> that it's related to removing items from list. I am putting the sample code below. How can I do this properly without this exception in my case.</p>

<pre><code>try 
{
    for(Game game:appDeleg.getGlobalGames().getGames())
    {
        if(game.getOwner().getId().equals(params[0]))
        {
            synchronized (appDeleg.getGlobalGames().getGames())
            {
                appDeleg.getGlobalGames().getGames().remove(game);
            }
        }

    }
}

catch (Exception e) 
{
    e.printStackTrace();
    return "noconnection";
}
</code></pre>
