GithubHelp home page GithubHelp logo

Comments (5)

jnharton avatar jnharton commented on June 2, 2024

For now, I'm going to switch that specific piece of code to use the function that gets a Client array (which I added back in ago in a recent commit under the alternate function name getClients_alt() )

from mud-server.

joshgit avatar joshgit commented on June 2, 2024

You can't modify a collection while iterating over it. This is a better fix:

    public Vector<Client> getClients() {
    return new ArrayList<Client>(clients);
}

It's almost always better to use collections and this just copies the current one.

from mud-server.

jnharton avatar jnharton commented on June 2, 2024

Do point out if I misunderstand. The thing is that it's possible to try to modify them and that could happen, and would then throw an exception. How is that an improvement? True it's a collection, but I can iterate over an array as well.

from mud-server.

joshgit avatar joshgit commented on June 2, 2024

You can iterate over either, especially since they are copies. It's only bad if you modify the original collection.  But working with arrays might mean you later want to modify it and can't.  Working with an ArrayList means you get all of the functionality of an array and an arraylist at essentially no cost, including things like contains().


From: Jeremy Harton [email protected]
To: jnharton/mud-server [email protected]
Cc: joshgit [email protected]
Sent: Friday, February 1, 2013 9:01 PM
Subject: Re: [mud-server] Problem with concurrent modification regarding the collection of client objects the server holds (#7)

Do point out if I misunderstand. The thing is that it's possible to try to modify them and that could happen, and would then throw an exception. How is that an improvement? True it's a collection, but I can iterate over an array as well.

Reply to this email directly or view it on GitHub.

from mud-server.

jnharton avatar jnharton commented on June 2, 2024

issue ought to be re-evaluated post merge.

from mud-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.