Member variable corruption
I have a very odd multi-threading problem that I've run out of ideas with. If anybody has any suggestions they'd be greatly appreciated.
Here's the structure, bottom up:
I have a class (we'll call it Engine) with some private member variables, and some local member variables in the methods.
I have another class that is Runnable, which we'll call SingleEngine. The run method instantiates Engine and calls a method within it, which will loop until flagged to exit.
A third class, called EngineController, instantiates 2 SingleEngines and starts them as threads.
So EngineController has 2 instances of SingleEngine, each being a thread, and each SingleEngine instantiates an Engine.
Now what I'm finding is, the class member variables in SingleEngine are somehow becoming equal between the two instances (and threads). I know I'm not looking at the same Engine object, because the local method variables are different. But if I change a class member variable in one instance of engine, it changes in the other, and netbeans tells me the variables are in fact pointing at exactly the same memory.
Neither of the two engines interact with each other. And some of the member variables are only accessed from within an Engine class. All of the class variables are private.
Just for an added twist, the application actually has more than 2 just of these SingleEngine threads running, yet the problem only happens between 2 of them (not consistent which 2).
I hope that makes sense. Does anybody have any ideas what to look at/what could be causing this? Feel free to ask for specific details, I'm trying to limit it to the basic description of what I have.