用单例模式,记录排队的人数,static count=0;int n=10;
有人进来就
PD:
if(count<n)
{
lock(_lock){
if(count<n)
{
count++;
//这里是处理
count--
}
else{
System.Threading.Thread.Sleep(800)//等待多少秒
goto PD;
}
}
else{
System.Threading.Thread.Sleep(1000)//等待多少秒
goto PD;
}
有人进来就
PD:
if(count<n)
{
lock(_lock){
if(count<n)
{
count++;
//这里是处理
count--
}
else{
System.Threading.Thread.Sleep(800)//等待多少秒
goto PD;
}
}
else{
System.Threading.Thread.Sleep(1000)//等待多少秒
goto PD;
}
可以明白点么?这个单例模式没怎么用过,好比System.Threading.Thread.Sleep(1000),为什么需要等待?goto PD;又是什么意思?_lock这个参数从哪里来?