Synchronization lock not required for scheduleAtFixedRate(new Runnable(){}) https://stackoverflow.com/a/35498230

This commit is contained in:
dbrownidau
2020-02-10 01:29:57 +11:00
parent 3eb6e87019
commit fb1321c8e0
@@ -164,8 +164,6 @@ public class GameEngine {
*/
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
if (lock.tryLock()) {
synchronized (lock) {
/**
* Main Server Tick
*/
@@ -215,10 +213,6 @@ public class GameEngine {
scheduler.shutdown(); // Kills the tickloop thread if Exception is thrown.
}
}
}
} else {
System.out.println("Can't Keep up! Did the system time change or is the server overloaded?");
}
}
}, 0, GameConstants.CYCLE_TIME, TimeUnit.MILLISECONDS);