Fix simulation sleep time

Fix: correct sleep time for the simulation thread by taking into account
elapsed time.