Changed some layouts, wasted a lot of time and made sure the LobbyDisplayHandler-Updater can only have one thread at a time that is writing to the same data
This commit is contained in:
parent
3b5b2da60e
commit
b3e520a2c3
@ -11,11 +11,20 @@ public class LobbyDisplayHandler {
|
||||
|
||||
|
||||
private static HashSet<LobbyModel> lobbies = new HashSet<>();
|
||||
private static boolean threadRunning = false;
|
||||
|
||||
public static HashSet<LobbyModel> getLobbies() {
|
||||
return lobbies;
|
||||
}
|
||||
|
||||
public static void setThreadRunning(boolean threadRunning) {
|
||||
LobbyDisplayHandler.threadRunning = threadRunning;
|
||||
}
|
||||
|
||||
public static boolean isThreadRunning() {
|
||||
return threadRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* searches lobbies for a lobby with a certain id
|
||||
* @param id the int representing a Lobby id to be lookes for
|
||||
@ -34,6 +43,14 @@ public class LobbyDisplayHandler {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while(isThreadRunning()) {
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
setThreadRunning(true);
|
||||
try {
|
||||
for (LobbyModel model : lobbies) {
|
||||
model.setHasBeenVisited(false);
|
||||
@ -58,8 +75,11 @@ public class LobbyDisplayHandler {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("empty list");
|
||||
} finally {
|
||||
setThreadRunning(false);
|
||||
}
|
||||
}
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user