I'm doing a cellular automatan that I'm running as an instance of a class with a specific thread provided for it. For the new functionality, namely adding live cells through mouse input while the simulation proceeds , I have to access the class' instance doing the simulation from the main thread, to modify its ArrayList> "world" named 2D container, that my Draw class uses to paint as a reference.
But ArrayList is not threadsafe and I get errors. At this point my "world" of cells is only 50x50, but I'd like to extend its size to 10000^2 or even much bigger. (I'd use quadTrees at that magnitudes)
So my question is, what kind of container should I use, that is both threadsafe, wouldn't take all system resources at higher magnitudes, and "compatible" with the quadTree concept.
I don't know lot about multithreading, should I scrap the idea if of bothering a heavy-weight thread like this or could I maybe pause the thread for the period of evaluating the user's input?(Actually I tried that, I put the thread to sleep and tried to access the instance in the meanwhile, no success.)
I've checked some threadsafe containers, their performance vary depending on if I just iterate over them or edit their properties and such. There are just too many things to consider, I'd really appreciate if someone could show me what direction to pick, Andrew.