Matching coding style; block potential race condition

Signed-off-by: Lucas Fairchild-Madar <lfairchildmadar@flightstats.com>
This commit is contained in:
Lucas Fairchild-Madar 2017-08-25 12:35:45 -07:00
parent 7d1d7a9724
commit 84ff1e3a66
1 changed files with 5 additions and 3 deletions

View File

@ -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);
}