Hi, I have a game loop like this:
while(true)
{
start = System.nanoTime();
draw();
if(inGame)update();
while(System.nanoTime() - start < 31250000)
{
Thread.yield();
}
Its a very simple loop for a lil application. However, when running it in both the IDE and as an executable jar, in runs at different speeds. Sometimes it runs normally, but often it’ll run slower than before. The speed dosnt change mid way - it’s either slow from start to end, or normal from start to end. Its a very simple program so it isnt just my CPU not being able to handle it. Is this a common problem, a fault with my loop or just my PC?