Latest Diablo 3 News
DiabloWiki Updates
Support the site! Become a Diablo: IncGamers PAL - Remove ads and more!

Concurrent Modification Exception?

Discussion in 'Off-Topic' started by eds01, Nov 9, 2006.

  1. eds01

    eds01 IncGamers Member

    Joined:
    Jun 26, 2003
    Messages:
    180
    Likes Received:
    0
    Trophy Points:
    86
    Concurrent Modification Exception?

    So I'm writing a program for my cse115 class (quite literaly, it has to do something with graphics, we get to decide what we're doing), and i'm running into an error i have no idea how I'm getting. The error is, as the title suggests, a Concurrent Modification Exception, and I'm programming in java. I'm pretty sure its from this one 2-d array that i have filled up with a type of graphic, but i'm not sure what's actualy wrong with it. What I'm doing with the array is just filling it up in a nested for loop, and then displaying the values on the screen. I'll post the code later (not currently at the lab where i have the code stored).
     
  2. Gertlex

    Gertlex Banned

    Joined:
    Feb 15, 2006
    Messages:
    2,912
    Likes Received:
    14
    Trophy Points:
    0
    I never learned that much java, but that error sounds like maybe you're using threads? Concurrently = at the same time, so two threads trying to modify the same variable at the same time?



     
  3. myleftfoot

    myleftfoot IncGamers Member

    Joined:
    Oct 8, 2004
    Messages:
    1,931
    Likes Received:
    0
    Trophy Points:
    165
    Are you removing items from the list?



     
  4. eds01

    eds01 IncGamers Member

    Joined:
    Jun 26, 2003
    Messages:
    180
    Likes Received:
    0
    Trophy Points:
    86
    As far as i know, the programs single threaded, and i'm not actualy removing any refrences - i made the graphic in the array a type of compound graphic, so i can just change what kind of circle is on the intersection (I'm coding a GUI for go, so theres only 3 states a intersection can have - it can have a black stone on it, a white stone or it can just have nothing). Also, i put the code for changing whats on the intersection to be inside the compound graphic, so other classes just call a playBlack() or playWhite() method.
     
  5. Eritar

    Eritar IncGamers Member

    Joined:
    Jun 22, 2003
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    11
    Assuming you're making some use of the Swing classes, I believe that Swing components get a separate thread of execution automatically. I think. :wink3: I'm no Java expert either, and knowing this doesn't really help you, anyway.
     
  6. eds01

    eds01 IncGamers Member

    Joined:
    Jun 26, 2003
    Messages:
    180
    Likes Received:
    0
    Trophy Points:
    86
    I think that the extended graphic that I'm useing comes from the libraries provided by the teachers (I'm currently at home and the codes at school, so...), but I wouldent be half suprised if the code in that extends java.awt and javax.swing.

    What can i do to stop the concurrent modification if it does in fact, come from the use of swing?
     
  7. Quietus

    Quietus IncGamers Member

    Joined:
    Mar 11, 2005
    Messages:
    5,470
    Likes Received:
    3
    Trophy Points:
    346
    I didn't pay that much attention in my Java class, unfortunately, but I'm pretty sure that I remember 2d graphics in Java working much the same as they did when I worked in C++... in which case, there's a good chance that what's happening is that you aren't locking the surface that you're working on. I'm afraid I can't be of much help in just giving the commands to do so, as I said, I didn't pay much attention to Java... but I distinctly remember having to lock a surface, draw to it, unlock it, then show it.

    As was pointed out before, Concurrent means "at the same time" - which means Concurrent Modification would mean two things trying to change something at the same time. That's going to end up pouring a pile of garbage out at you, ending up in an error like this. Try troubleshooting, and see if you can figure out which variables are being altered when the program crashes.
     

Share This Page