The writing of field WebSockdtImpl.readyState is synchronized in close methods. The checking method, like WebSocketImpl.isOpen(), isClosing() etc., should also be synchronized. Because these methods may be called in any other thread, and the thread could see a local copy of the variable readyState. The simplest way is adding a key word volatile to readyState.
The writing of field WebSockdtImpl.readyState is synchronized in close methods. The checking method, like WebSocketImpl.isOpen(), isClosing() etc., should also be synchronized. Because these methods may be called in any other thread, and the thread could see a local copy of the variable
readyState. The simplest way is adding a key wordvolatiletoreadyState.