try{
request_mon.enter();
IPToHostNameResolverRequest request = new IPToHostNameResolverRequest( ip, l );
request_queue.add( request );
request_semaphore.release();
if ( resolver_thread == null ){
resolver_thread =
new AEThread("IPToHostNameResolver")
{
public void
runSupport()
{
while(true){
try{
request_semaphore.reserve();
IPToHostNameResolverRequest req;
try{
request_mon.enter();
req = (IPToHostNameResolverRequest)request_queue.remove(0);
}finally{
request_mon.exit();
}
IPToHostNameResolverListener listener = req.getListener();
// if listener is null the request has been cancelled
if ( listener != null ){
try{
InetAddress addr = InetAddress.getByName( req.getIP());
req.getListener().IPResolutionComplete( addr.getHostName(), true );
}catch( Throwable e ){
req.getListener().IPResolutionComplete( req.getIP(), false );
}
}
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
}
};
resolver_thread.setDaemon( true );
resolver_thread.start();
}
return( request );
}finally{
request_mon.exit();
}