mirror of
https://github.com/revanced/jadb.git
synced 2025-02-11 09:36:48 +01:00
Refactor: Moving out methods for clarity.
This commit is contained in:
parent
ce6f04bdc7
commit
c2acf534ff
@ -22,11 +22,7 @@ public abstract class SocketServer implements Runnable {
|
||||
thread = new Thread(this, "Fake Adb Server");
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
synchronized (lockObject) {
|
||||
if (!isStarted) {
|
||||
lockObject.wait();
|
||||
}
|
||||
}
|
||||
serverReady();
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
@ -39,10 +35,7 @@ public abstract class SocketServer implements Runnable {
|
||||
socket = new ServerSocket(port);
|
||||
socket.setReuseAddress(true);
|
||||
|
||||
synchronized (lockObject) {
|
||||
lockObject.notify();
|
||||
isStarted = true;
|
||||
}
|
||||
waitForServer();
|
||||
|
||||
while (true) {
|
||||
Socket c = socket.accept();
|
||||
@ -54,6 +47,21 @@ public abstract class SocketServer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void serverReady() throws InterruptedException {
|
||||
synchronized (lockObject) {
|
||||
if (!isStarted) {
|
||||
lockObject.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForServer() {
|
||||
synchronized (lockObject) {
|
||||
lockObject.notify();
|
||||
isStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Runnable createResponder(Socket socket);
|
||||
|
||||
public void stop() throws IOException, InterruptedException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user