一个关于超长的不重复随机序列的问题
匿写一个在10000000~90000000范围内生成一个长大100000项的不重复序列
最终程序到32202处apache死机。。。不知道是为什么。。
c# 写类似算法
private void button1_click(object sender, eventargs e)
{
thread t = new thread(tt);
t.isbackground = true;
t.start();
}
private void tt() {
for (int i = 0; i {
string temp = r.next(0, 80000000).tostring(); ;
if (!l.contains(temp))
{
l.add(temp);
i++;
}
}
messagebox.show(0k);
}
则没有问题
但是跨线程访问label用以监控变量i时,c#的label也会发生异常。。
不知道是我哪里做错了,还是有其他解决方案?
------解决方案--------------------
试跑了一下,i路到了31408,呵呵。
------解决方案--------------------
php中int的最大值为32769。可能是溢出的缘故吧。
php code
------解决方案--------------------