从数据库中读取到DataTable循环读出里面的数据private void TestThread()
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//这里操作数据
}
}循环操作时间比较长,所以我想用多线程来操作for (int t = 0; t < 5; t++)
{
Thread td1 = new Thread(new ThreadStart(TestThread));
td1.Start();
}
这样写多线程好像有问题,速度还是很慢, 我想怎么样让一个线程操作一条数据,其它线程去读下一条数据,这个怎么实现呢?
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//这里操作数据
}
}循环操作时间比较长,所以我想用多线程来操作for (int t = 0; t < 5; t++)
{
Thread td1 = new Thread(new ThreadStart(TestThread));
td1.Start();
}
这样写多线程好像有问题,速度还是很慢, 我想怎么样让一个线程操作一条数据,其它线程去读下一条数据,这个怎么实现呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货