- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
《Ping_JAVA_测试程序》.doc
package util.net;
import java.util.*;
class PingHelper
{
private static final String CMD = CMD /C PING ;
private Process cmdProcess;
public int ping(String ip){
try{
cmdProcess = Runtime.getRuntime().exec(CMD+ip);
cmdProcess.waitFor();
//System.out.println(cmdProcess.exitValue());
return cmdProcess.exitValue();
}catch(Exception e){
e.toString();
}finally{
if(cmdProcess != null)
cmdProcess.destroy();
}
return -1;
}
public static void main (String[] args) {
PingHelper pm = new PingHelper();
System.out.println(RETURN: +pm.ping(127.0.0.2));
}
}
public class PingMaster implements Runnable
{
private PingHelper pingHelper;
private Integer sleepTime;
private HashMapString,Integer pingMap;
public PingMaster(Integer sleepTime,HashMapString,Integer pingMap){
this.pingHelper = new PingHelper();
this.sleepTime = sleepTime;
this.pingMap = pingMap;
}
public synchronized void setPingStatus(String pingIP,Integer pingStatus){
pingMap.put(pingIP,pingStatus);
}
public HashMapString,Integer getPingStatus(){
return this.pingMap;
}
public void run(){
while(true){
SetString pingIPs = pingMap.keySet();
for(String pingIP : pingIPs){
int pingStatus = pingHelper.ping(pingIP);
setPingStatus(pingIP,pingStatus);
}
try{
Thread.sleep(sleepTime);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}
public static void main (String[] args) throws InterruptedException {
HashMapString,Integer map = new HashMap();
map.put(192.168.0.1,1);
map.put(192.168.2.32,1);
map.put(127.0.0.1,1);
PingMaster p = new PingMaster(2000,map);
Thread t = new Thread(p);
t.join();
t.start();
while(true){
map = p.getPingStatus();
SetString set = map.keySet();
String datetime = (new Date()).toLocaleString();
for(String s : set){
System.out.println(*-*-* +datetime + Ping-Report *-*-*);
System.out.println(Ping + Status: +map.get(s));
Thread.sleep(1500)
您可能关注的文档
- 《linux系统DNS服务器》.pdf
- 《Linux系统培训》.ppt
- 《Linux系统工程师必学的系统管理命令》.doc
- 《Linux系统工程师面试题大全101》.doc
- 《linux课程设计报告》.doc
- 《Linux运维工程师面试题总结》.pdf
- 《Linux运维精品视频课程推荐【4.21更新】》.docx
- 《Linux配置Apache服务器全攻略》.pdf
- 《Linux配置Java开发环境》.doc
- 《Linux高级开发培训》.pdf
- 《plc_led指示灯Getting_LED_Status》.pdf
- 《PMC Level2 考题》.xls
- 《PNAS-2016-Chang-Light-emitting eReaders negatively affects sleep》.pdf
- 《Pneumatics Basic Level by FESTO_095001》.pdf
- 《pneumatic_muscle_actuator_technology_a_light_weight_power_system_for》.pdf
- 《Policy Guide on Agricultural Land Preservation 2人》.pdf
- 《Politeness and Psychological Distance A Construal Level Perspective》.pdf
- 《Polycyclic aromatic hydrocarbons in urban soils of different land uses in Beijing》.pdf
- 《PPT图标模板(Juniper+拓扑图标)》.ppt
- 《Prediction of cogging torque level in PM motors due to assembly tolerances in mass-production》.pdf
最近下载
- GBZ40846-2021 工程咨询 基本术语 (2).pdf VIP
- 机械制图--机械制图基础知识.ppt VIP
- 疑难伤口MDT全面管理新理念题库答案 - 2025年华医网继续教育.docx VIP
- 瑞升华蒸汽机械再压缩(MVR)蒸发器——技术交流课件.ppt VIP
- 《瑞升华蒸汽机械再压缩MVR蒸发器——技术交流.ppt VIP
- PICO384非制冷红外焦平面驱动成像方案研究.PDF VIP
- Q 320481 DWT002-2016_机械蒸汽再压缩(MVR)蒸发器.pdf VIP
- GB50868-2013 建筑工程容许振动标准.pdf VIP
- 2025年军事职业测试题及答案.doc VIP
- 学校食堂管理规章制度.docx VIP
文档评论(0)