static List<string> list = new List<string>();
static void Main(string[] args)
{
new Thread(Go).Start();
new Thread(Go).Start();
Console.Read();
}
static void Go()
{
for (int i = 0; i < 100; i++)
{
lock (list)
list.Add("Item" + list.Count);
string[] items;
lock (list)
items = list.ToArray();
foreach (string s in items)
{
Console.WriteLine(s);
}
}
}请问下这段代码为什么会先出来100以后的呢,
如果屏蔽掉一个线程,就会从56,57,然后就是0-99呢??
帮顶
这代码排版,让人怎么看?