JAVA如何生成不重复的随机数

JAVA怎么生成不重复的随机数
这个不是J2SE的Math那个随机数,是J2ME里的,但JVM的工作原理应该是一样的,所以在这里求解了。

Random random = new Random();

int random.nextInt(6);//生成0~5之间的随机整数

我想生成0~5这六个随机int,在线程里分别试过上面的方法,按概率算,连续生成的两个随机数重复的概率应该是1/6*1/6=1/36,线程运行36 次才会有一次重复,但是我线程运行的结果大让我郁闷,生成的随机数重复的太多了,有时连续重复十几次,这还是随机的么?


我又做了一点试验,发现程循环间隔越长,重复就越少,间隔越短,重复就越多。

比如Thread.sleep(10)就连续的十几次会重复,Thread.sleep(200)重复的就很少,但是我不可能为了得到不重复的随机数把线程睡眠时间拉长。

大侠们有更好的办法减少两个连续的随机数重复的概率没? 很头痛,真纠结。当然,运算最好简单点,手机内存受不了的。

能在
(int)System.currentTimeMillis()%6;//获取当前线程运行时间模六
 上做点文章么??

我只剩20分了,谢谢了。

------解决方案--------------------
试一下,应该可以的.
public void test(){
try{
Vector v = new Vector();
for(int i = 0;i<10;i++){
Random random = new Random();
int k =  random.nextInt(6);
if(v.contains(k)){
int j = (Integer)v.get(0);
if(j+1 <6){
v.removeAll(v);
v.add(j+1);
System.out.println(j+1);
Thread.sleep(10);
}else{
v.removeAll(v);
v.add(j-1);
System.out.println(j-1);
Thread.sleep(10);
}
}else{
v.removeAll(v);
v.add(k);
System.out.println(k);
Thread.sleep(10);
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
------解决方案--------------------

/**
 * @随机数组
 * 生成一个由大于零的随机整数组成的数组,且数组中没有重复的值。
 * 
 * @author 
 * @email 
 */
import java.util.Arrays;

public class RandomArray {

 /*
  * 测试代码
  */
 public static void main(String[] args) {
  RandomArray ra = new RandomArray();
  System.out.println(Arrays.toString(ra.getRandomArray(10)));
 }

 /**
  * 将新获得的随机数与已产生的其它随机数相比较,若有重复数据,则丢弃,并重来一遍;
  * 否则,将新数存入数组。
  * 
  * @param i 数组的大小
  * @return 随机数组
  */
 public int[] getRandomArray(int i) {
  int[] a = new int[i]; // a 随机数数组
  for (int m = 0; m < i; m++) { // m 已产生的随机数个数
   int temp = random();
   if (m == 0)
    a[0] = temp;
   else {
    for (int n = 0; n < m; n++) { // n 遍历已产生的随机数
     if (temp == a[n]) {
      temp = random();
      n = -1;
     }
    }
    a[m] = temp;
   }
  }
  return a;
 }

 /**
  * 随机数发生器
  * 0 <= Math.random() < 1
  * 
  * @return 1至10之间的随机整数
  */
 private int random() {
  return (int) (10 * Math.random() + 1);