diff --git a/src/main/java/net/jonathangiles/tools/teenyhttpd/TeenyHttpd.java b/src/main/java/net/jonathangiles/tools/teenyhttpd/TeenyHttpd.java index 24bec3a..9ba99b8 100755 --- a/src/main/java/net/jonathangiles/tools/teenyhttpd/TeenyHttpd.java +++ b/src/main/java/net/jonathangiles/tools/teenyhttpd/TeenyHttpd.java @@ -21,6 +21,7 @@ import java.net.URLDecoder; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.Function; @@ -55,7 +56,9 @@ public class TeenyHttpd { private ServerSocket serverSocket; - private boolean isRunning = false; + private volatile boolean isRunning = false; + + private CountDownLatch startLatch; private final Map>> routes = new HashMap<>(); @@ -135,11 +138,16 @@ private void _addRoute(final Method method, final String path, final Function handleIncomingRequest(clientSocket));