Java获得一段代码运行时间的方法和线程延时
/**
* 获得一段代码运行时间的方法和线程延时
* @author 尹永贤
* @time 2014年10月12日 10:09:50
* @Email [email protected]
*/
public class RunTime {
public static void main(String[] args) {
// TODO Auto-generated method stub
long start = System.currentTimeMillis(); //开始时间
//runcode();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//毫秒
long end = System.currentTimeMillis(); //结束时间
System.out.println("运行时间:"+(end-start)+"毫秒");
}
}