diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java index ec7a769cdfa..ac5b9377e05 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java @@ -704,15 +704,17 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont * @see Runtime#addShutdownHook(Thread) * @see ShutdownThread */ - public void setStopAtShutdown(boolean stop) + public synchronized void setStopAtShutdown(boolean stop) { if (stop) { - if (!stopAtShutdown && isStarted() && !ShutdownThread.isRegistered(this)) { + if (!stopAtShutdown && isStarted() && !ShutdownThread.isRegistered(this)) + { ShutdownThread.register(this); } } - else { + else + { ShutdownThread.deregister(this); }