110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
public class Program
{
private static List<LOCK> LockList = new List<LOCK>();
public class LOCK
{
public LOCK(int uid, DateTime t)
{
UserId = uid;
PostTime = t;
}
public long UserId { get; set; }
public DateTime PostTime { get; set; }
}
static List<Thread> threads = new List<Thread>();
static Random ran = new Random();
static void Main(string[] args)
{
for (int i = 0; i < 99; i++)
{
Thread xx = new Thread(new ThreadStart(str));
xx.Start();
threads.Add(xx);
}
Console.WriteLine(11111);
}
private static void str()
{
while (true)
{
int id = ran.Next(1000000, 9000000);
LockList.Add(new LOCK(id, DateTime.Now));
System.Threading.Thread.Sleep(10);
LockList.RemoveAll(x => x.UserId == id);
}
}
}
}
大哥,有什麼办法解决。