mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed double thread issue! :D
This commit is contained in:
@@ -91,7 +91,6 @@ public class GameState implements Runnable {
|
||||
|
||||
resetStartTime();
|
||||
|
||||
new Thread(this).start(); //Run the auto updates on the game state
|
||||
new Thread(this, "GameState").start(); //Run the auto updates on the game state
|
||||
|
||||
marks = new MarkOrder().getAllMarks();
|
||||
|
||||
@@ -13,7 +13,7 @@ import seng302.gameServer.server.messages.Message;
|
||||
* Will call .clientDisconnected on the delegate when a heartbeat message
|
||||
* cannot be sent to a player
|
||||
*/
|
||||
public class HeartbeatThread extends Thread{
|
||||
public class HeartbeatThread implements Runnable {
|
||||
private final int HEARTBEAT_PERIOD = 200;
|
||||
private ClientConnectionDelegate delegate;
|
||||
private Integer seqNum;
|
||||
@@ -23,6 +23,9 @@ public class HeartbeatThread extends Thread{
|
||||
this.delegate = delegate;
|
||||
seqNum = 0;
|
||||
disconnectedPlayers = new Stack<>();
|
||||
|
||||
Thread thread = new Thread(this, "HeartBeat");
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,14 +56,9 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
|
||||
|
||||
|
||||
public void run() {
|
||||
ServerListenThread serverListenThread;
|
||||
HeartbeatThread heartbeatThread;
|
||||
|
||||
serverListenThread = new ServerListenThread(serverSocket, this);
|
||||
heartbeatThread = new HeartbeatThread(this);
|
||||
|
||||
heartbeatThread.start();
|
||||
serverListenThread.start();
|
||||
new HeartbeatThread(this);
|
||||
new ServerListenThread(serverSocket, this);
|
||||
|
||||
//You should handle interrupts in some way, so that the thread won't keep on forever if you exit the app.
|
||||
while (!terminated) {
|
||||
|
||||
@@ -8,13 +8,16 @@ import java.net.Socket;
|
||||
* A class for a thread to listen to connections
|
||||
* Created by wmu16 on 11/07/17.
|
||||
*/
|
||||
public class ServerListenThread extends Thread{
|
||||
public class ServerListenThread implements Runnable {
|
||||
private ServerSocket serverSocket;
|
||||
private ClientConnectionDelegate delegate;
|
||||
|
||||
public ServerListenThread(ServerSocket serverSocket, ClientConnectionDelegate delegate){
|
||||
this.serverSocket = serverSocket;
|
||||
this.delegate = delegate;
|
||||
|
||||
Thread thread = new Thread(this, "ServerListen");
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user