登录
登录 注册新账号
注册
已有账号登录
学会项目管理 工作少点难题
qiusuo 阅读 198 次
5月28日发布

点击网盘download:学会项目管理 工作少点难题

项目管理无处不在,它不仅仅是一个岗位,更是一套科学的工作方法,能够很好地指导我们的工作与生活。但很多开发者缺少项目管理意识与技巧,为自己的工作增添了许多额外的阻碍,不仅项目推进不及预期,也让个人职场发展受限。本课程带你系统性学习项目管理,让你不管做开发还是转PM,都能游刃有余!

 

技术适合人群要求
刚毕业的大学生、在职的开发人员
想转型项目管理的开发者、任何对项目管理感兴趣的人员
技术储备要求
会使用Office、会下载和安装软件
 
import java.io.IOException;

import java.net.InetAddress;

import java.net.UnknownHostException;

/**

 * Created by QiuJU

 * on 2014/9/21.

 */

public class SimplePing implements Runnable {

    private final Object mEndLock = new Object();

    private boolean IsEnd = false;

    private int arrivedCount = 0;

    private int Count;

    private int TimeOut;

    private String Name;

    private int mEndCount;

    private String mIp = null;

    private float mLossRate = 1f;

    private float mDelay = 0;

    public SimplePing(String name, int count, int timeOut) {

        Count = mEndCount = count;

        TimeOut = timeOut;

        Name = name;

        for (int i = 0; i < mEndCount; i++) {

            Thread thread = new Thread(this);

            thread.setDaemon(true);

            thread.start();

        }

        if (!IsEnd) {

            try {

                synchronized (mEndLock) {

                    mEndLock.wait();

                }

            } catch (InterruptedException e) {

                e.printStackTrace();

            }

        }

    }

    private void setEnd(boolean isArrived, long delay, String ip) {

        synchronized (mEndLock) {

            Count--;

            if (isArrived) {

                arrivedCount++;

                mDelay = (mDelay + delay) / 2f;

                if (ip != null)

                    mIp = ip;

            }

        }

        if (Count == 0)

            setEnd();

    }

    private void setEnd() {

        mLossRate = (mEndCount - arrivedCount) / mEndCount;

        IsEnd = true;

        synchronized (mEndLock) {

            mEndLock.notifyAll();

        }

    }

    Override

    public void run() {

        long delay = 0;

        boolean isArrived = false;

        String ip = null;

        try {

            long startTime = System.currentTimeMillis();

            InetAddress address = InetAddress.getByName(Name);

            isArrived = address.isReachable(TimeOut);

            delay = System.currentTimeMillis() - startTime;

            ip = address.getHostAddress();

        } catch (UnknownHostException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        } catch (Exception e) {

            e.printStackTrace();

        } finally {

            setEnd(isArrived, delay, ip);

        }

    }

    public String getIp() {

        return mIp;

    }

    public float getLossRate() {

        return mLossRate;

    }

    public float getDelay() {

        return mDelay;

    }

    public boolean getIsSucceed() {

        return arrivedCount > 0;

    }

}

在类中运用的是:
1

2

3

4

5

long startTime = System.currentTimeMillis();

            InetAddress address = InetAddress.getByName(Name);

            isArrived = address.isReachable(TimeOut);

            delay = System.currentTimeMillis() - startTime;

            ip = address.getHostAddress();