Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • zConcurrentModificationException


    Scorpius

    Recommended Posts

    Posted

    Why does it have to be on dreambot ??? Its a general java programming practice, just google concurrency in java lol

     

    What I mean is, the effort you spend on criticizing can be spent on something more productive.

    Posted

    What I mean is, the effort you spend on criticizing can be spent on something more productive.

    not rlly, it didnt take any effort for me to type that comment

    Posted

    not rlly, it didnt take any effort for me to type that comment

    just leaving this there for memories

    Posted

    Just use a fori loop, the CurrentModificationException is thrown because you are editing the List in a for-each loop which uses an iterator. The iterator checks if something changed on every iteration, meaning as soon as you remove or add something the next iteration will throw this error. Using a fori loop you evade this iterator being used resulting in no error being thrown.

    Posted

    Just use a fori loop, the CurrentModificationException is thrown because you are editing the List in a for-each loop which uses an iterator. The iterator checks if something changed on every iteration, meaning as soon as you remove or add something the next iteration will throw this error. Using a fori loop you evade this iterator being used resulting in no error being thrown.

    But removing from the list while the loop is running somewhere still throws an exception, I'd solve it the same way I am solving it now

    Posted

    But removing from the list while the loop is running somewhere still throws an exception, I'd solve it the same way I am solving it now

    1. Stop using for-each loops and use fori instead
    2. If you are multi-threading and accessing this list from multiple Threads use synchronized blocks eventhough you should be fine only using fori
    Posted

     

    1. Stop using for-each loops and use fori instead
    2. If you are multi-threading and accessing this list from multiple Threads use synchronized blocks eventhough you should be fine only using fori

     

    I'll definitely be doing those very soon, thank you fella!

    Posted

    just use List#addAll

     

    avoiding iterator alone isnt thread safe.  you still should use a concurrent collection or synchronized block.  a concurrent collection makes more sense in this case.  CopyOnWriteArrayList (or ConcurrentLinkedQueue if u dont need indexed access)

    Posted

    just use List#addAll

     

    avoiding iterator alone isnt thread safe.  you still should use a concurrent collection or synchronized block.  a concurrent collection makes more sense in this case.  CopyOnWriteArrayList (or ConcurrentLinkedQueue if u dont need indexed access)

    I'm adding/removing/reading at the same time on 3 different threads, still thinking about approaches tbh but every answer in here is a step forward.

    • 2 weeks later...
    Posted

    I'll be writing a tutorial on concurrency/object locking/mutex in the general programming section this week, if you really intend to learn

    where's ur guide big mouth

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.