We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a separate thread for my gameloop locked at 150hz, and VSync turned on so draw() runs at the monitors refresh rate. This works great for keeping the gameplay stable, responsive, with smooth graphics.
I'm a java noob, I've tried many different mixes of using synchronized (), volatile, CopyOnWriteArrayList, I can't seem to avoid getting random crashes on my gamethread. Things like modifying an arraylist or pshape in the gameloop and accessing it for drawing seem to cause problems. The errors vary but it's usually complaining about not finding a vertex or arraylist entry it expected to find or java.util.ConcurrentModificationException for arraylists in the gameloop, EmpyStackException when using resetMatrix() on a pshape from inside my draw loop. Sometimes it manifests as drawing corrupted versions of my PShapes.
What's the recommended method to go about doing this and keeping it safe? Sometimes I can play my game for 10+ minutes without a problem, sometimes it will lock up right away several times in a row.
https://indielm.itch.io/platformbattler here's the game, it was made very quick for a jam so I'd need to clean up the code before sharing it.