Minor refactor, threads now start themselves

tags: #story[989] #refactor
This commit is contained in:
William Muir
2017-07-22 16:45:24 +12:00
parent a0005064ac
commit 3ec930491f
5 changed files with 33 additions and 10 deletions
@@ -20,11 +20,13 @@ import seng302.utilities.GeoPoint;
* All server threads created and owned by the server thread handler which can trigger client updates on its threads
* Created by wmu16 on 13/07/17.
*/
public class ServerToClientThread extends Thread {
public class ServerToClientThread implements Runnable {
private static final Integer LOG_LEVEL = 1;
private static final Integer MAX_ID_ATTEMPTS = 10;
private Thread thread;
private InputStream is;
private OutputStream os;
private Socket socket;
@@ -50,6 +52,9 @@ public class ServerToClientThread extends Thread {
Random rand = new Random();
sourceId = rand.nextInt(100000);
GameState.addYacht(sourceId, new Yacht("Kappa", "Kap", new GeoPoint(0.0, 0.0), 0.0));
thread = new Thread(this);
thread.start();
}
@@ -185,4 +190,9 @@ public class ServerToClientThread extends Thread {
readByte();
}
}
public Thread getThread() {
return thread;
}
}