private void replaceSocket ( Socket newSocket ) { synchronized ( m_socketLock ) { closeSocket ( m_socket ) ; if ( m_eos . get ( ) ) { closeSocket ( newSocket ) ; m_socket = null ; } else { m_socket = newSocket ; } } }
Set the socket to newSocket unless we re shutting down . The most reliable way to ensure the importer thread exits is to close its socket .