Refactor: Better names

- serverReady and waitForServer had inverted names for some reason.
This commit is contained in:
Samuel Carlsson 2016-10-01 14:10:48 +02:00
parent 2073817c95
commit 24348f806d

View File

@ -22,7 +22,7 @@ public abstract class SocketServer implements Runnable {
thread = new Thread(this, "Fake Adb Server");
thread.setDaemon(true);
thread.start();
serverReady();
waitForServer();
}
public int getPort() {
@ -35,7 +35,7 @@ public abstract class SocketServer implements Runnable {
socket = new ServerSocket(port);
socket.setReuseAddress(true);
waitForServer();
serverReady();
while (true) {
Socket c = socket.accept();
@ -47,7 +47,14 @@ public abstract class SocketServer implements Runnable {
}
}
private void serverReady() throws InterruptedException {
private void serverReady() {
synchronized (lockObject) {
isStarted = true;
lockObject.notify();
}
}
private void waitForServer() throws InterruptedException {
synchronized (lockObject) {
if (!isStarted) {
lockObject.wait();
@ -55,13 +62,6 @@ public abstract class SocketServer implements Runnable {
}
}
private void waitForServer() {
synchronized (lockObject) {
lockObject.notify();
isStarted = true;
}
}
protected abstract Runnable createResponder(Socket socket);
public void stop() throws IOException, InterruptedException {