title: java.util.ConcurrentModificationException - Android
body: <p>I am getting the following exception from the following piece of code sometimes
  People suggest that if I make the for loop to an iterator, It would fix the issue. But I don't understand If I am not removing any element inside the for loop but calling pendingActions.clear(); later. 
  Please let me know if anyone has come across any of this scenario.
  Also , Would you think if I make list declaration to  </p>
  
  <pre><code>private List&lt;Action&gt; pendingActions = Collections.synchronizedList(new ArrayList&lt;&gt;()); 
  </code></pre>
  
  <p>will fix the issue ?</p>
  
  <pre><code> private List&lt;Action&gt; pendingActions = new ArrayList&lt;&gt;();
  
  private void runPendingNavigationActions() {
          if (!pendingActions.isEmpty()) {
              for (Action r : pendingActions) {
                  r.run();
              }
              pendingActions.clear();
          }
      } 
  </code></pre>
  
  <h2>Exception:</h2>
  
  <pre><code>at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4156)
      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4250)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1839)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7229)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
      Caused by: java.util.ConcurrentModificationException
      at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
      at com.app.android.view.fragment.MainFragment.runPendingNavigationActions(MainFragment.java:1355)
  </code></pre>