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

  • Home
  • SEARCH
  • 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 8458643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:08:06+00:00 2026-06-10T13:08:06+00:00

I’m trying to write a game engine, in which a list of list of

  • 0

I’m trying to write a game engine, in which a list of list of sprites is used to hold all sprites (The list of lists lets me order the sprites in a sensible manner). The problem is, I need to repeatedly add and remove sprites, something that violates the fail-fast iterators pretty quickly, giving me a concurrent modification exception. Can I have multiple iterators on a list, and will this stop the exceptions? Failing this, is there a way to ‘release’ a list’s iterator, so that the list no longer checks for modifications?

  • 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-10T13:08:08+00:00Added an answer on June 10, 2026 at 1:08 pm

    Can I have multiple iterators on a list, and will this stop the exceptions?

    Yes you can, and no it won’t. (The iterator checks the state of the list to determine if a concurrent modification has occurred.)

    Failing this, is there a way to ‘release’ a list’s iterator, so that the list no longer checks for modifications?

    No there isn’t, at least not with the standard list classes. And it would be a bad idea because it would be likely to lead to the kind of anomalies and data corruptions that fail-fast iterators are designed to avoid. (Would you prefer your application to fail predictably with a ConcurrentModificationException, or fail occasionally with random data structure corruptions and/or weird exceptions?)

    I think you need to look at alternative List implementation class in which the iterators allow concurrent modifications. Depending on how your application is using the list, the possibilities include:

    • CopyOnWriteArrayList this has full list semantics, but write operations tend to be a bit expensive.

    • ConcurrentLinkedDeque this most of the operations you’d expect on a list (but not positional insert or remove), and write operations are cheaper.

    In both cases, the iterators provide weaker guarantees about whether or not the iteration will see all elements. You need to read the respective javadocs carefully to be sure that the semantics are suitable.

    With a couple of historical exceptions, the collection types in java.util are not designed for concurrent / multi-threaded use cases. If your application requires collection types that are accessed by multiple threads, you need to look at the implementations in the java.util.concurrent package.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.