Error when attaching state

I noticed when you try to attach a state from the onAction function using the action listener it throws this exception java.util.ConcurrentModificationException. Wouldn’t using an iterator be safer way to do this ?

private synchronized void attach(AppState state) {
Iterator iterator = states.iterator();
while(iterator.hasNext()) {
if (!states.contains(state) && !initializing.contains(state)){

Edit: never mind I had my threads crossed :slight_smile:

My humble advice: do yourself a favor and use BaseAppState instead of reinventing the wheel.

Note: and for this to have affected you at all then presumably you are overriding stateAttached(). Generally, do not do anything on stateAttached() and stateDetached(). They are provided only for debugging purposes and some backward compatibility. They are dangerous to use otherwise since they are not called on the render thread like the other methods. (They are called on whatever thread did the attaching.)