synchronized(disconnect_mutex) { try { disconnect_ok_event_received=false; down(disconnect_event); while(!disconnect_ok_event_received) disconnect_mutex.wait(); } catch(Exception e) { if(log.isErrorEnabled()) log.error("exception: " + e); } }
disconnect_promise.reset(); down(disconnect_event); disconnect_promise.getResult();
    public synchronized void disconnect() {        if(closed) return;        if(connected) {            if(channel_name != null) {                /* Send down a DISCONNECT event. The DISCONNECT event travels down to the GMS, where a                *  DISCONNECT_OK response is generated and sent up the stack. JChannel blocks until a                *  DISCONNECT_OK has been received, or until timeout has elapsed.                */                Event disconnect_event=new Event(Event.DISCONNECT, local_addr);                synchronized(disconnect_mutex) {                    try {                        disconnect_ok_event_received=false;                        down(disconnect_event);   // DISCONNECT is handled by each layer                        while(!disconnect_ok_event_received)                            disconnect_mutex.wait();  // wait for DISCONNECT_OK event                    }                    catch(Exception e) {                        if(log.isErrorEnabled()) log.error("exception: " + e);                    }                }            }            // Just in case we use the QUEUE protocol and it is still blocked...            down(new Event(Event.STOP_QUEUEING));            connected=false;            try {                prot_stack.stopStack(); // calls stop() in all protocols, from top to bottom            }            catch(Exception e) {                if(log.isErrorEnabled()) log.error("exception: " + e);            }            if(channel_listener != null)                channel_listener.channelDisconnected(this);            init(); // sets local_addr=null; changed March 18 2003 (bela) -- prevented successful rejoining        }    }