一个线程  随机sleep 1-10 秒  然后再运行  
然后重复上面的过程 .... 
请问该怎么写 ....

解决方案 »

  1.   

    while(true){
       int i=Math.random()*10;
       Thread.sleep(i);
    }
      

  2.   

    while(true)
    {
      int a = "通过radom获得随机数";
      Thread.currentThread.sleep(a*1000);
    }
      

  3.   

    while(true){
       int i=Math.random()*10000;
       Thread.sleep(i);
    }
    sleep  方法里面的参数是毫秒。。  调用Math里面的random方法是实现随机取 0~1 的数。
    所以我们在对变量i进行赋值的时候要乘以10000才能转化成秒
      

  4.   

    这个是测试用的  ...谢谢 ....
    while(true)  这个是什么意思 ?  控制一直循环 ?
      

  5.   


    while(true){
      int i=Math.random()*10000;
      Thread.sleep(i);
      System.out.println("this time sleep i/1000 second");
    }