private static void interruptThreadSafely ( QueryThread thread ) { try { thread.interrupt(); } catch ( SecurityException e ) { e.printStackTrace(); } }
NetbiosAddress lookupServerOrWorkgroup ( String name, InetAddress svr ) throws UnknownHostException { Sem sem = new Sem(2); int type = isWINS(svr) ? 0x1b : 0x1d; QueryThread q1x = new QueryThread(sem, name, type, null, svr, this.transportContext); QueryThread q20 = new QueryThread(sem, name, 0x20, null, svr, this.transportContext); q1x.setDaemon(true); q20.setDaemon(true); try { synchronized ( sem ) { q1x.start(); q20.start(); while ( sem.count > 0 && q1x.getAnswer() == null && q20.getAnswer() == null ) { sem.wait(); } } } catch ( InterruptedException ie ) { throw new UnknownHostException(name); } waitForQueryThreads(q1x, q20); if ( q1x.getAnswer() != null ) { return q1x.getAnswer(); } else if ( q20.getAnswer() != null ) { return q20.getAnswer(); } else { throw q1x.getException(); } }
NetbiosAddress lookupServerOrWorkgroup ( String name, InetAddress svr ) throws UnknownHostException { Sem sem = new Sem(2); int type = isWINS(svr) ? 0x1b : 0x1d; QueryThread q1x = new QueryThread(sem, name, type, null, svr, this.transportContext); QueryThread q20 = new QueryThread(sem, name, 0x20, null, svr, this.transportContext); q1x.setDaemon(true); q20.setDaemon(true); try { synchronized ( sem ) { q1x.start(); q20.start(); while ( sem.count > 0 && q1x.getAnswer() == null && q20.getAnswer() == null ) { sem.wait(); } } } catch ( InterruptedException ie ) { throw new UnknownHostException(name); } waitForQueryThreads(q1x, q20); if ( q1x.getAnswer() != null ) { return q1x.getAnswer(); } else if ( q20.getAnswer() != null ) { return q20.getAnswer(); } else { throw q1x.getException(); } }
private static void interruptThreadSafely ( QueryThread thread ) { try { thread.interrupt(); } catch ( SecurityException e ) { e.printStackTrace(); } }