#vulnerable code 
                                public void disconnect() throws IOException {
        try {
            connected = false;
            if (channel != null) {
                channel.close();
            }
        } finally {
            synchronized (lifecycleListeners) {
                for (LifecycleListener lifecycleListener : lifecycleListeners) {
                    lifecycleListener.onDisconnect(this);
                }
            }
        }
    } 
                            #location 5 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public void disconnect() throws IOException {
        shutdownLock.lock();
        try {
            if (isKeepAliveThreadRunning()) {
                keepAliveThreadExecutor.shutdownNow();
            }
            disconnectChannel();
        } finally {
            shutdownLock.unlock();
        }
        if (isKeepAliveThreadRunning()) {
            waitForKeepAliveThreadToBeTerminated();
        }
    }