Use Thread.yield() in order to make active waiting less painful.

This commit is contained in:
Jan Philipp Timme 2014-10-24 23:45:31 +02:00
parent f26c9366cd
commit b132fac7b0
1 changed files with 5 additions and 1 deletions

View File

@ -40,7 +40,11 @@ public abstract class TimingThread extends Thread {
//wait manually for the rest of the interval //wait manually for the rest of the interval
long sleepUntil = workStart + this.workInterval; long sleepUntil = workStart + this.workInterval;
while ((sleepUntil- System.nanoTime()) > 100); while ((sleepUntil- System.nanoTime()) > 0) {
if((sleepUntil- System.nanoTime()) > 5000) {
Thread.yield(); //Give other threads a chance.
}
}
} }
} }