mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-01-18 10:23:58 +08:00
Run post game processing asynchronously
This commit is contained in:
parent
e95f4d5a61
commit
b80f81cb51
@ -371,8 +371,18 @@ public class GameRound implements Runnable {
|
||||
broadcastPlayerList();
|
||||
|
||||
long start = System.nanoTime();
|
||||
try {
|
||||
ManagedScheduledExecutorService exec = InitialContext.doLookup("java:comp/DefaultManagedScheduledExecutorService");
|
||||
exec.submit(() -> {
|
||||
updatePlayerStats();
|
||||
});
|
||||
exec.submit(() -> {
|
||||
lifecycleCallbacks.forEach(c -> c.gameEnding());
|
||||
});
|
||||
} catch (NamingException e) {
|
||||
log("Unable to perform post game processing");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Wait for 5 seconds, but subtract the amount of time it took to update player stats
|
||||
long nanoWait = TimeUnit.SECONDS.toNanos(5) - (System.nanoTime() - start);
|
||||
|
Loading…
Reference in New Issue
Block a user