日期:2014-05-17 浏览次数:21003 次
public int ping(String ip) {
return InetAddress.getByName(host).isReachable(5000)?1:0;
}
String[] iparray = new String[500];
//......
for (int i=0; i<iparray.length; i++) {
int result = ping(iparray[i]);
}
------解决方案--------------------
public int ping(String ip) {
return InetAddress.getByName(ip).isReachable(5000)?1:0;
}
String[] iparray = new String[500];
//......
for (int i=0; i<iparray.length; i++) {
int result = ping(iparray[i]);
}
------解决方案--------------------
采用多线程:
for (Integer i = 1; i <= station; i++) {
String ip = pro.getPropertyValue("station" + i.toString(), "ip");
MonitorThread myThread = new MonitorThread(i, ip);
threads[i] = new Thread(myThread);
threads[i].start();
}