This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic  RSS feed

Rajal Mistry
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Friends,
I am trying to write a net work management module , so, in a thread i m calling InetAddress.getByName("");
wh9ich is on my intranet , so when it is on the n/w the code below shows it is on the network by printing it but as my thread is running and if this system goes out of n/w InetAddress.getByName(""); should throw a exception and show it is not on network (what i feel), but it is not going into the exception part inside the thread. Now if i come out of my program and again starts it it is going to exception and showing the message
that system is not on n/w .and again if the system is brought back on the network inside the thread it is not showing that
it is on n/w.
Is there anything i m doing worng ..
If anybody can tell a little about the inner implementation of InetAddress, please.
code goes here :::
public class InetAddressTest
public static void main(String args[])
SystemsOnNetwork sysonnet=new SystemsOnNetwork();
}catch(Exception ie)

class SystemsOnNetwork implements Runnable{

Thread th;
String curr = "";

th = new Thread(this);

public void run()
while (true)
InetAddress Inet = InetAddress.getByName(curr); System.out.println(" System is on n/w");
}catch(UnknownHostException uhe){
System.out.println(" System is not on n/w");

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!