ConcurrentModificationException

Hi,



if I draw something new in my HUD, I try to delete the old TextureState. However, from time to time I get a ConcurrentModificationException. Is it possible to avoid this, or should I just ignore it? Here is the code:



   protected void setBufferedImage(BufferedImage bi, Quad quad) {
        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
        Texture t = TextureManager.loadTexture(bi, Texture.MM_LINEAR, Texture.MM_LINEAR, 1, false);
        ts.setTexture(t);
       
        final TextureState oldTs = (TextureState)quad.getRenderState(RenderState.RS_TEXTURE);
       
        quad.setRenderState(ts);
        quad.updateRenderState();
       
        if(oldTs != null) {
            GameTaskQueueManager.getManager().update(new Callable<Object>() {
                public Object call() throws Exception {
                    try {
                    oldTs.deleteAll(true);
                    } catch (ConcurrentModificationException ex) {
                        /*hmmm*/
                    }
                    return null;
                }
            });
        }
       
    }

What thread is calling setBufferedImage?

Normally it's called from update methods of some controllers, but for initialization etc. it's also called from the normal main application.



How can I get more infos which thread makes problems? (sorry, this sounds noobish, but I have only a very fuzzy idea about threads in JME)

try putting the entire setBufferedImage call into GameTaskQueue and see if that makes a difference.

Thanks, I'll try it!

So far no exceptions, it seems to work!

Threading can be a pain. :wink: