Getting consistent speed with JBox2d app

Hi all,

I’ve just been messing about with JBox2D, and it seems pretty great. The only problem I have is getting an app to run at a constant speed when run on different PCs. It runs fine on a fast PC, but slow on a slower PC. Do I need to throttle the game loop like you would in any other game, or does it do that automatically? E.g. is the following okay:-

 while (true) {
            world.step(timeStep, velocityIterations, positionIterations);
 }

or should it be more like:

 while (true) {
            world.step(timeStep, velocityIterations, positionIterations);
            Thread.sleep(1000/fps);
 }

And do I need to tweak the params I’m passing to World.step(), ie. timeStep, velocityIterations, and positionIterations, for better performance?

Thanks in advance!

EDIT: By looking at the testbed examples, I’ve seen that the latter is correct. However, my own app seems to run very slow. I’ve got a gravity of (0, -10) and I’ve created a ball with a density of 10,000. However, it still takes about 10 seconds to drop 600.