player update optimized
This commit is contained in:
@@ -45,18 +45,12 @@ public class UpdateThread implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
lastRun = System.currentTimeMillis();
|
lastRun = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (System.currentTimeMillis() >= lastRun + instancedelay) { // Correct condition
|
try {
|
||||||
this.processPlayerUpdate();
|
this.processPlayerUpdate();
|
||||||
lastRun = System.currentTimeMillis(); // Update lastRun after processing
|
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
||||||
}else {
|
} catch (InterruptedException e) {
|
||||||
try {
|
Logger.error("Thread interrupted", e);
|
||||||
Thread.sleep(100); // Pause for 100ms to reduce CPU usage
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Logger.error("Thread interrupted", e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Thread.yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user