simpleInitApp not getting called (multiple headless threads)

I have a simulation worker app that extends SimpleApplication and implements Runnable. I run this thing headless (a pp.start(JmeContext.Type.Headless); ) because I don’t need visualization in the simulation (I need it later to view results).

The problem is that when I run multiple threads at the same time the simpleInitApp method gets called only on first 4 threads.

I can’t figure out why is that so. I tried calling simpleInitApp myself and it works then but then the simpleInitApp is called twice (2x) on every thread.

Here’s the code to run the threads:

int populationSize = 50;

for(int i=0; i<populationSize; i++)


Thread oThread = new Thread(new OrganismEvolution(UUID.randomUUID().toString(), true));

synchronized (oThread)








Plz help!

I think you might be a bit confused.

You only have one application, therefore you should only have one SimpleApplication. And even that’s questionable since you’ve already declared that you don’t need any of the things that SimpleApplication is giving you.

Maybe you need to take a step back and explain why your application needs so many applications inside of it.

Each application creates a “organism” (boxes connected with joints) that then runs for 15seconds and I then get the result of how far it has traveled.

Because I’m applying genetic algorithms to it I need huge populations of those “organisms” and I don’t want to run those one after another because it would take too long.

Thread != Application.

Why not just create threads for the things you want? Why do they all have to be applications? That’s what I’m still trying to figure out.

Running your calculations on separate threads won’t speed it up. They still take turns as threads, just unpredictable and chopped up turns. You want multithreading if you are loading assets or running long routines that will make the rendering pause. Since you are running headless, that does not matter. So just run them all back-to-back and avoid the threading headache.

Now if you do have many cores, threads can help. But do not launch multiple applications to do this.

Thanks guys.

It seemed good idea at the time when I started doing this, but now I see it’s kinda overkill.

Because my “organism” is on a simple plane where I test how far it can travel, I decided to run multiple “organisms” on seperated planes (one above/beyond other, because they don’t need much height.

Seems better than running multiple threads…

Either way… in the future… if you create more than one SimpleApplication you are doing it wrong. It’s like buying several car dealerships because you need a few cars.