public class RandomNumberDemo 
{
public static void getTime()
{
long start = System.currentTimeMillis();
runCode();
long end = System.currentTimeMillis();
System.out.println("本次运行所用时间是:"+(end-start));
}
/*public static void runCode()
{
for(int i=0; i<10000; i++)
{
System.out.println(i);//9999  本次运行所用时间是:185
}
}*/
/*public static void runCode()
{
int b=0;
for(int i=0; i<10000; i++)
{
//[9999]  本次运行所用时间是:244
b = (int) Math.round(Math.random()*10);//而产生0和10之间的整数,则会写成: Math.round(Math.random()*10)
System.out.println("["+i+"]"+b);
}
}*/
public static void runCode()
{
int c=0;
for(int i=0; i<10000; i++)
{
c= java.util.concurrent.ThreadLocalRandom.current().nextInt(100);//本次运行所用时间是:243
System.out.println("["+i+"]"+c);
}
}
public static void main(String[] args)
{
RandomNumberDemo.getTime();
}
}