title: java ConcurrentModificationException even with synchronized
body: <p>Similar issue has been posted before but this case is different - there is static usage which may be the complicating it.
  Just want to see if anyone has ideas on how to handle this.
  I get the ConcurrentModificationException even though I am using synchronzed on the list around both blocks that modify it.</p>
  
  <pre><code>public class Foo {
     public void register() {
         FooManager.addFoo(this);
     }
  }
  
  public class ABC1 {
     static Foo myfoo;
     static {
       myfoo = new Foo();
       myfoo.register();
     }
  }
  </code></pre>
  
  <p>(I have mutliple similar classes ABC2, ABC3)</p>
  
  <pre><code>public class FooManager {
     static ArrayList&lt;Foo&gt; m_globalFoos;
     static ABC1 m_abc;
     static {
       m_globalFoos = new ArrayList&lt;Foo&gt;();
       m_abc = new ABC1();
     }
  
  
     public static void addFoo(Foo foo) {
       synchronized(m_globalFoos) { // SYNC
           m_globalFoos.add(foo);
        }
     }
  
      public static void showFoos() {
          synchronized(m_globalFoos) { //SYNC
              for (Foo foo : m_globalFoos) {
                       foo.print();
              }
      }
  }
  </code></pre>
  
  <p>I declare
  ABC1, ABC2, ABC3 etc in more than 1 thread func.
  In my main program, first line</p>
  
  <pre><code>main() {
      FooManager.showFoos();
  </code></pre>
  
  <p>Exception details:</p>
  
  <pre><code>Exception in thread "main" java.util.ConcurrentModificationException
          at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
          at java.util.AbstractList$Itr.next(AbstractList.java:343)
          at com.mytest.FooManager.showFoos(FooManager.java:78)
          at com.mytest.FooTest.main(FooTest.java:109)
  </code></pre>