01: // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: /**
06: * A special-purpose thread used by Resolvers (both SimpleResolver and
07: * ExtendedResolver) to perform asynchronous queries.
08: *
09: * @author Brian Wellington
10: */
11:
12: class ResolveThread extends Thread {
13:
14: private Message query;
15: private Object id;
16: private ResolverListener listener;
17: private Resolver res;
18:
19: /** Creates a new ResolveThread */
20: public ResolveThread(Resolver res, Message query, Object id,
21: ResolverListener listener) {
22: this .res = res;
23: this .query = query;
24: this .id = id;
25: this .listener = listener;
26: }
27:
28: /**
29: * Performs the query, and executes the callback.
30: */
31: public void run() {
32: try {
33: Message response = res.send(query);
34: listener.receiveMessage(id, response);
35: } catch (Exception e) {
36: listener.handleException(id, e);
37: }
38: }
39:
40: }
|