Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:18:37+00:00 2026-06-02T06:18:37+00:00

I got a ConcurrentModificationExeption in what I thought to be a single thread case.

  • 0

I got a ConcurrentModificationExeption in what I thought to be a single thread case. I also know that if you iterate through a List and try to modify it in the loop, you would have an exception. Hence I actually iterate and modify it using an iterator. However, I still have the exception.

Basically, I am implementing some animation manager, and I store all my IAnimation objects in an ArrayList. There is one public method that changes the list, which is addAnimation. THere is another method that loops through the list, which is calculateTick. Since both methods are synchronized, I dont think I have a threading problem. And as mentioned earlier, I iterate thruogh the loop using the iterator. Do you guys have any ideas why I have this exception?

Here is my code:

    private List<IAnimation> animations = new ArrayList<IAnimation>();
    public synchronized void addAnimation(IAnimation animation) {
    animations.add(animation);
    mLooper.update();
    inAnimation = true;
}

public synchronized void calculateTick(float tpf) {     
    for (Iterator<IAnimation> iterator = animations.iterator(); iterator.hasNext();) {
        IAnimation animation= iterator.next();
                    boolean animateMore = animation.calculateTick(tpf);
        if (!animateMore ) {{
            iterator.remove();
        }
    }

}

And here is my exception:

 E/AndroidHarness(9546): Exception thrown in Thread[GLThread 1260,5,main]

04-17 11:55:38.001: E/AndroidHarness(9546): java.util.ConcurrentModificationException
04-17 11:55:38.001: E/AndroidHarness(9546): at java.util.ArrayList$ArrayListIterator.remove(ArrayList.java:582)
04-17 11:55:38.001: E/AndroidHarness(9546): at com.avaya.mco.gui.animation.AnimationManager.calculateTick(AnimationManager.java:50)
04-17 11:55:38.001: E/AndroidHarness(9546): at com.avaya.mco.gui.jmonkey.android.MyApplication.simpleUpdate(MyApplication.java:60)
04-17 11:55:38.001: E/AndroidHarness(9546): at ……

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:18:38+00:00Added an answer on June 2, 2026 at 6:18 am

    are you sure there is no other function missing here that iterates over the list ? maybe something that plays the animation?

    also, if that doesn’t help , try using “ConcurrentLinkedQueue” :
    http://developer.android.com/reference/java/util/concurrent/ConcurrentLinkedQueue.html
    it’s available to all versions , and it says that for the iterator :
    “…The returned iterator is a “weakly consistent” iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got an activity that extends ListActivity . The list is backed up by a
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
Got a c#.net app which I need to modify. The query at the moment
Got a task to make a program that registers animals and the object is
Got a list saved by using .data(). How is it possible to find exact
Got that error when trying to push updated app to Heroku (probably the same
Got a mobile site with a jquery mobile menu (nested-list). Every item in the
Got a situation where we have a working production website that is moving to
Got this error when parsing my html page using XPATH.. i am also using
Got a class that serializes into xml with XMLEncoder nicely with all the variables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.