Ensure looping runnable sleeps at least a little

This commit is contained in:
Matt
2019-11-22 07:50:25 -08:00
parent fc311b3f03
commit 9d023a43f0

View File

@@ -23,11 +23,15 @@ public abstract class LoopingRunnable implements Runnable {
// sleep for the remaining time
var timeElapsed = System.currentTimeMillis() - now;
var delta = loopTimeMs - timeElapsed;
if(delta > 0.0) {
try {
try {
if(delta > 0.0) {
Thread.sleep(delta, 0);
} catch (Exception ignored) {}
}
} else {
Thread.sleep(1);
}
} catch (Exception ignored) {}
}
}
}