question: @ Override public void run ( ) { logger . finest ( "LookupDiscovery - Requestor thread started" ) ; int count ; try { if ( delayFlag && ( initialMulticastRequestDelayRange > 0 ) && ( multicastRequestMax >= 0 ) ) { Thread . sleep ( ( long ) ( Math . random ( ) * initialMulticastRequestDelayRange ) ) ; } for ( count = multicastRequestMax ; -- count >= 0 && ! isInterrupted ( ) ; ) { DatagramPacket [ ] reqs = encodeMulticastRequest ( new MulticastRequest ( multicastRequestHost , responsePort , groups , getServiceIDs ( ) ) ) ; sendPacketByNIC ( sock , reqs ) ; Thread . sleep ( count > 0 ? multicastRequestInterval : finalMulticastRequestInterval ) ; } } catch ( InterruptedException e ) { } catch ( InterruptedIOException e ) { } catch ( Exception e ) { logger . log ( Level . INFO , "exception while marshalling outgoing " + "multicast request" , e ) ; } finally { synchronized ( requestors ) { requestors . remove ( Thread . currentThread ( ) ) ; if ( respondeeThread != null && requestors . isEmpty ( ) ) { respondeeThread . interrupt ( ) ; respondeeThread = null ; } } sock . close ( ) ; logger . finest ( "LookupDiscovery - Requestor thread completed" ) ; } }
target:  This method sends out N (for small N) multicast requests. Until the last request is sent out, this method sleeps for 5 seconds after each request is sent. After the last request is sent, this method sleeps for 2 minutes to allow the ResponseListener time to receive and process any multicast responses sent in reply to the multicast requests. Before sending a request, a new multicast request is constructed so that updates can be made to the set of service IDs of the lookup services discovered due to previous requests. <p> After all requests have been sent, and the ResponseListener has been given the appropriate time to receive and process any multicast responses, if there are no more active instances of this thread, this method terminates (interrupts) the ResponseListener. Note that although it is more desirable to have the ResponseListener set a timeout on the server socket (using setSoTimeout) and then simply exit after a period of time in which both the ResponseListener has been idle, and there have been no active Requestor threads, using setSoTimeout in this way can cause random hangs on the Solaris(TM) operating system.