Looks like the SteeringBehaviors library is determining the simulation time by calling System.currentTimeMillis()
, so (unless you modify the library) your only option is to call runSimulation()
at exactly the right time.
Consider spawning 2 threads:
- Execute Thread 1 every time the display needs to be updated (e.g., by syncing to the display's refresh interval)
- Execute Thread 2 every time you want to update the simulation. Make sure this thread executes at the same rate on different platforms (e.g., by setting it up to fire using a fixed-rate timer).
(And, of course, be sure that any data structures shared between those two threads (the locations of the particles, for example) are protected from thread collisions (e.g., using locks).)
That way, if the rendering thread stalls, or if the rendering speed differs between hardware devices, your simulation thread will continue to update the simulation at a constant rate.