public Object sendAsync ( final Message query , final ResolverListener listener ) { final Object id ; synchronized ( this ) { id = new Integer ( uniqueID ++ ) ; } Record question = query . getQuestion ( ) ; String qname ; if ( question != null ) qname = question . getName ( ) . toString ( ) ; else qname = "(none)" ; String name = this . getClass ( ) + ": " + qname ; Thread thread = new ResolveThread ( this , query , id , listener ) ; thread . setName ( name ) ; thread . setDaemon ( true ) ; thread . start ( ) ; return id ; }
Asynchronously sends a message to a single server registering a listener to receive a callback on success or exception . Multiple asynchronous lookups can be performed in parallel . Since the callback may be invoked before the function returns external synchronization is necessary .