标签:style blog java 数据 2014 for
有没有人想过1ms里面java能做什么?很多人说计算机很快快到无法想象1ms的时间内java能做很多时间,有的人说java很慢1ms里面做不了太多事情。今天我用实验来告诉大家究竟1ms里面java能做什么,java究竟有多快(或者有多慢)
public class A {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.println(System.currentTimeMillis());
}
}
}实验输出结果:1406079200638 1406079200638 1406079200638 …… 1406079200638 1406079200639 1406079200639 1406079200639 1406079200639 …… 1406079200639 1406079200639 1406079200639 1406079200639 1406079200640 …… 1406079200640 1406079200640
/**
* 计数器
* @author alexy
*
*/
public class B {
private HashMap<Long, Integer> counter = new HashMap<Long, Integer>();
public HashMap<Long, Integer> getCounter() {
return counter;
}
public void setCounter(HashMap<Long, Integer> counter) {
this.counter = counter;
}
}public class A {
public static void main(String[] args) {
B b = new B();
for (int i = 0; i < 100; i++) {
long time = System.currentTimeMillis();
Integer count = b.getCounter().get(time);
if(count == null){
count = new Integer(1);
System.out.println(time + " : " + count);
b.getCounter().put(time, count);
}else{
int newCount = count.intValue() + 1;
System.out.println(time + " : " + newCount);
b.getCounter().put(time, newCount);
}
}
}
}1406080147962 : 1 1406080147962 : 2 1406080147963 : 1 1406080147963 : 2 1406080147963 : 3 1406080147963 : 4 1406080147963 : 5 1406080147963 : 6 1406080147963 : 7 1406080147963 : 8 1406080147963 : 9 1406080147963 : 10 1406080147963 : 11 1406080147963 : 12 1406080147963 : 13 1406080147964 : 1 1406080147964 : 2 1406080147964 : 3 1406080147964 : 4 1406080147964 : 5 1406080147964 : 6 1406080147964 : 7 1406080147964 : 8 1406080147964 : 9 1406080147964 : 10 1406080147964 : 11 1406080147964 : 12 1406080147964 : 13 1406080147964 : 14 1406080147964 : 15 1406080147964 : 16 1406080147964 : 17 1406080147964 : 18 1406080147964 : 19 1406080147964 : 20 1406080147964 : 21 1406080147964 : 22 1406080147964 : 23 1406080147964 : 24 1406080147964 : 25 1406080147964 : 26 1406080147964 : 27 1406080147964 : 28 1406080147964 : 29 1406080147964 : 30 1406080147964 : 31 1406080147964 : 32 1406080147964 : 33 1406080147964 : 34 1406080147964 : 35 1406080147964 : 36 1406080147965 : 1 1406080147965 : 2 1406080147965 : 3 1406080147965 : 4 1406080147965 : 5 1406080147965 : 6 1406080147965 : 7 1406080147965 : 8 1406080147965 : 9 1406080147965 : 10 1406080147965 : 11 1406080147965 : 12 1406080147965 : 13 1406080147965 : 14 1406080147965 : 15 1406080147965 : 16 1406080147965 : 17 1406080147965 : 18 1406080147965 : 19 1406080147965 : 20 1406080147965 : 21 1406080147965 : 22 1406080147965 : 23 1406080147965 : 24 1406080147965 : 25 1406080147965 : 26 1406080147965 : 27 1406080147965 : 28 1406080147965 : 29 1406080147965 : 30 1406080147965 : 31 1406080147966 : 1 1406080147966 : 2 1406080147966 : 3 1406080147966 : 4 1406080147966 : 5 1406080147966 : 6 1406080147966 : 7 1406080147966 : 8 1406080147966 : 9 1406080147966 : 10 1406080147966 : 11 1406080147966 : 12 1406080147966 : 13 1406080147966 : 14 1406080147966 : 15 1406080147966 : 16 1406080147966 : 17 1406080147966 : 18
1ms的时间内java能干什么?,布布扣,bubuko.com
标签:style blog java 数据 2014 for
原文地址:http://blog.csdn.net/nsrainbow/article/details/38058123