Buggy code:
public class JmDNSImpl extends JmDNS { private static final boolean isIphone = Boolean . getBoolean ( "net.mdns.isArmDarwin" ) ; private InetAddress group ; private MulticastSocket socket ; private boolean closed = false ; private List listeners ; private Map serviceListeners ; private List typeListeners ; private DNSCache cache ; Map services ; Map serviceTypes ; private Thread shutdown ; private HostInfo localHost ; private Thread incomingListener = null ; private int throttle ; private long lastThrottleIncrement ; Timer timer ; private static final Random random = new Random ( ) ; private Object ioLock = new Object ( ) ; private DNSIncoming plannedAnswer ; private DNSState state = DNSState . PROBING_1 ; private TimerTask task ; private final HashMap serviceCollectors = new HashMap ( ) ; public JmDNSImpl ( ) throws IOException { } public JmDNSImpl ( InetAddress addr ) throws IOException { } private void init ( InetAddress address , String name ) throws IOException { } private void start ( Collection serviceInfos ) { } private void openMulticastSocket ( HostInfo hostInfo ) throws IOException { } private void closeMulticastSocket ( ) { } public synchronized void advanceState ( ) { } synchronized void revertState ( ) { } synchronized void cancel ( ) { } public DNSState getState ( ) { } public DNSCache getCache ( ) { } public String getHostName ( ) { } public HostInfo getLocalHost ( ) { } public InetAddress getInterface ( ) throws IOException { } public ServiceInfo getServiceInfo ( String type , String name ) { } public ServiceInfo getServiceInfo ( String type , String name , int timeout ) { } public void requestServiceInfo ( String type , String name ) { } public void requestServiceInfo ( String type , String name , int timeout ) { } void handleServiceResolved ( ServiceInfoImpl info ) { } public void addServiceTypeListener ( ServiceTypeListener listener ) throws IOException { } public void removeServiceTypeListener ( ServiceTypeListener listener ) { } public void addServiceListener ( String type , ServiceListener listener ) { } public void removeServiceListener ( String type , ServiceListener listener ) { } public void registerService ( ServiceInfo infoAbstract ) throws IOException { } public void unregisterService ( ServiceInfo infoAbstract ) { } public void unregisterAllServices ( ) { if ( ( services . size ( ) ) == 0 ) { return ; } Collection list ; synchronized ( this ) { list = new LinkedList ( services . values ( ) ) ; services . clear ( ) ; } for ( final Iterator iterator = list . iterator ( ) ; iterator . hasNext ( ) ; ) { ( ( ServiceInfoImpl ) ( iterator . next ( ) ) ) . cancel ( ) ; } final Object lock = new Object ( ) ; new Canceler ( this , list , lock ) . start ( timer ) ; try { synchronized ( lock ) { if ( ! ( closed ) ) { <START_BUG> lock . wait ( ) ; <END_BUG> } } } catch ( final InterruptedException e ) { } } public void registerServiceType ( String type ) { } private boolean makeServiceNameUnique ( ServiceInfoImpl info ) { } String incrementName ( String name ) { } public void addListener ( DNSListener listener , DNSQuestion question ) { } public void removeListener ( DNSListener listener ) { } public void updateRecord ( long now , DNSRecord rec ) { } void handleResponse ( DNSIncoming msg ) throws IOException { } void handleQuery ( DNSIncoming in , InetAddress addr , int port ) throws IOException { } public DNSOutgoing addAnswer ( DNSIncoming in , InetAddress addr , int port , DNSOutgoing out , DNSRecord rec ) throws IOException { } public void send ( DNSOutgoing out ) throws IOException { } public void startAnnouncer ( ) { } public void startRenewer ( ) { } public void schedule ( TimerTask task , int delay ) { } private class Shutdown implements Runnable { public void run ( ) { } } public void recover ( ) { } public void close ( ) { } void print ( ) { } public void printServices ( ) { } public String toString ( ) { } public ServiceInfo [ ] list ( String type ) { } private void disposeServiceCollectors ( ) { } private static class ServiceCollector implements ServiceListener { private final Map infos = Collections . synchronizedMap ( new HashMap ( ) ) ; public String type ; public ServiceCollector ( String type ) { } public void serviceAdded ( ServiceEvent event ) { } public void serviceRemoved ( ServiceEvent event ) { } public void serviceResolved ( ServiceEvent event ) { } public ServiceInfoImpl [ ] list ( ) { } public String toString ( ) { } } private static String toUnqualifiedName ( String type , String qualifiedName ) { } public void setState ( DNSState state ) { } public void setTask ( TimerTask task ) { } public TimerTask getTask ( ) { } public Map getServices ( ) { } public void setLastThrottleIncrement ( long lastThrottleIncrement ) { } public long getLastThrottleIncrement ( ) { } public void setThrottle ( int throttle ) { } public int getThrottle ( ) { } public static Random getRandom ( ) { } public void setIoLock ( Object ioLock ) { } public Object getIoLock ( ) { } public void setPlannedAnswer ( DNSIncoming plannedAnswer ) { } public DNSIncoming getPlannedAnswer ( ) { } void setLocalHost ( HostInfo localHost ) { } public Map getServiceTypes ( ) { } public void setClosed ( boolean closed ) { } public boolean isClosed ( ) { } public MulticastSocket getSocket ( ) { } public InetAddress getGroup ( ) { } }

Fix:
lock . wait ( 1000 ) ;