日期:2014-05-17 浏览次数:20911 次
static void Main(string[] args)
{
for (var i = 0; i < 5; i++)
{
Thread thread = new Thread(new ParameterizedThreadStart(ThreadMainWithParameters));
thread.Start(i);
}
Console.ReadKey();
}
public static void ThreadMainWithParameters(object num)
{
var list =productService.GetALL();//这里获取数据集,
lock (obj)
{
foreach (var i in list)
{
Console.WriteLine(i.name);
Thread.Sleep(500);
//list.Remove(i);//foreach是只读的,不可移除啊,
}
}