diff --git a/src/AsyncSocket.java b/src/AsyncSocket.java index e91019d..7f1c535 100644 --- a/src/AsyncSocket.java +++ b/src/AsyncSocket.java @@ -24,6 +24,11 @@ public class AsyncSocket { this.checkerThread = new Thread(() -> { while (!this.shouldStop) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } try { if (!this.in.ready()) continue; if (this.handler == null) continue; @@ -31,16 +36,11 @@ public class AsyncSocket { String message = this.in.readLine(); if (message.length() <= 0) continue; + // TODO: remove \r\n this.handler.receive(message); } catch (IOException e) { e.printStackTrace(); } - - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } } }); this.checkerThread.start();