if(log.isInfoEnabled()) log.info("unicast receiver thread terminated");
if(log.isDebugEnabled()) log.debug("unicast receiver thread terminated");
        public void run() {            DatagramPacket  packet;            byte            receive_buf[]=new byte[65535];            int             len;            byte[]          data, tmp;            // moved out of loop to avoid excessive object creations (bela March 8 2001)            packet=new DatagramPacket(receive_buf, receive_buf.length);            while(running && thread != null && sock != null) {                try {                    packet.setData(receive_buf, 0, receive_buf.length);                    sock.receive(packet);                    len=packet.getLength();                    data=packet.getData();                    if(len == 1 && data[0] == 0) {                        if(log.isTraceEnabled()) log.trace("received dummy packet");                        continue;                    }                    if(log.isTraceEnabled())                        log.trace("received (ucast) " + len + " bytes from " +                                packet.getAddress() + ":" + packet.getPort());                    if(len > receive_buf.length) {                        if(log.isErrorEnabled()) log.error("size of the received packet (" + len + ") is bigger than " +                                                               "allocated buffer (" + receive_buf.length + "): will not be able to handle packet. " +                                                               "Use the FRAG protocol and make its frag_size lower than " + receive_buf.length);                    }                    if(Version.compareTo(data) == false) {                        if(log.isWarnEnabled()) log.warn("packet from " + packet.getAddress() + ":" + packet.getPort() +                                   " has different version (" +                                   Version.printVersionId(data, Version.version_id.length) +                                   ") from ours (" + Version.printVersionId(Version.version_id) +                                   "). This may cause problems");                    }                    if(use_incoming_packet_handler) {                        tmp=new byte[len];                        System.arraycopy(data, 0, tmp, 0, len);                        incoming_queue.add(tmp);                    }                    else                        handleIncomingUdpPacket(data);                }                catch(SocketException sock_ex) {                        if(log.isInfoEnabled()) log.info("unicast receiver socket is closed, exception=" + sock_ex);                    break;                }                catch(InterruptedIOException io_ex) { // thread was interrupted                    ; // go back to top of loop, where we will terminate loop                }                catch(Throwable ex) {                    if(log.isErrorEnabled()) log.error("[" + local_addr + "] exception=" + ex +                                                           ", stack trace=" + Util.printStackTrace(ex));                    Util.sleep(300); // so we don't get into 100% cpu spinning (should NEVER happen !)                }            }             if(log.isInfoEnabled()) log.info("unicast receiver thread terminated");        }