Multithreaded jME physics

Quick technical question. I know you can set a jBullet physics space to parallel threaded. What exactly does that do? Does the physics app state create and manage its own internal thread? Is it a single thread separate from your main thread then? Do I need to worry about synchronizing access to it, or is such handled internally to the app state object?



Also, what if I have multiple different bullet app states and I set each of them to parallel? Does each one of them have its own thread? So 4 app states = 4 threads + 1 main thread + any other misc threads (network controller, etc.) ?

Yes to all, if you do the manipulation on the update loop thread (or a physics tick callback of that specific physics space) you are safe. As mentioned in the manual they are run in parallel as well but they ofc don’t interact with each other. Actually they are run on an executor so the actual number of threads is dependent on the CPU count.

for proper functionality with multiple BulletAppStates (i.e not to collide with each other), they need to be run in parallel

Actually by default they are run sequentially which also works fine.