Use Thread.yield() in order to make active waiting less painful.
This commit is contained in:
parent
f26c9366cd
commit
b132fac7b0
|
@ -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.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue