Can anyone figure out why the code below only works if I add a dummy statement in the loop? Sleep(0) also works, but without any statement it simply wont run (ie. the update method on the updatable isn’t called), no errors are given.
The ticking boolean is always true (insterted if i ever wish to pause the routine), updateNextCycle and msPassed are set by the main game loop. (the reason this is in a thread is because I don’t want the game loop to wait for the update method to complete. Busy is used to indicate to the main loop that the previous update isn’t ready yet).
@Override
public void run() {
while(ticking) {
int i = 0; //@todo figure out why this is needed
if (updateNextCycle) {
busy = true;
updateNextCycle = false;
updatable.update(msPassed);
busy = false;
}
}
}