• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
2 
3 package org.xbill.DNS;
4 
5 /**
6  * A special-purpose thread used by Resolvers (both SimpleResolver and
7  * ExtendedResolver) to perform asynchronous queries.
8  *
9  * @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, ResolverListener listener)21 ResolveThread(Resolver res, Message query, Object id,
22 	      ResolverListener listener)
23 {
24 	this.res = res;
25 	this.query = query;
26 	this.id = id;
27 	this.listener = listener;
28 }
29 
30 
31 /**
32  * Performs the query, and executes the callback.
33  */
34 public void
run()35 run() {
36 	try {
37 		Message response = res.send(query);
38 		listener.receiveMessage(id, response);
39 	}
40 	catch (Exception e) {
41 		listener.handleException(id, e);
42 	}
43 }
44 
45 }
46