public void blockUtilConnected ( ) { if ( getStatus ( ) . isConnected ( ) ) { return ; } int to = getConnectTimeOut ( ) ; final Object o = new Object ( ) ; long now = System . currentTimeMillis ( ) ; synchronized ( o ) { ServiceDirectoryListener listener = new ServiceDirectoryListener ( ) { @ Override public void notify ( ServiceDirectoryEvent event ) { synchronized ( o ) { o . notifyAll ( ) ; } } } ; registerClientChangeListener ( listener ) ; try { while ( to > 0 ) { if ( getStatus ( ) . isConnected ( ) ) { return ; } try { o . wait ( to ) ; } catch ( InterruptedException e ) { LOGGER . warn ( "Block Util Connected interrupted." ) ; } to -= ( System . currentTimeMillis ( ) - now ) ; } } finally { unregisterClientChangeListener ( listener ) ; } } }
Block util the connect complete .