日期:2014-05-17 浏览次数:20811 次
Dictionary<int,int> dic=new Dictionary<int, int>(); void Button1Click(object sender, EventArgs e) { dic.Clear(); ThreadPool.QueueUserWorkItem(new WaitCallback(Method1),new object()); ThreadPool.QueueUserWorkItem(new WaitCallback(Method2),new object()); } void Method1(object o) { for (int i = 0; i < 50000; i++) { dic.Add(i,i); } Console.WriteLine("Method1 Count:"+dic.Count); } void Method2(object o) { for (int i = 50000; i < 100000; i++) { dic.Add(i,i); } Console.WriteLine("Method2 Count:"+dic.Count); }