线程内定义变量不会出现线程安全问题吧,就类似与这样的,每次查询都要在select方法里面去定义新建一个ibatis的connection的id?
IList<TaskNameAndNumber> taskNames = new List<TaskNameAndNumber>() ;
System.Threading.Tasks.Task[] theadTasks = new System.Threading.Tasks.Task[list.Count-1];
for (int i = 0; i < list.Count-1; i++)
{
theadTasks[i]=System.Threading.Tasks.Task.Factory.StartNew(()=> {
TaskCondition taskCondition = new TaskCondition();
taskCondition.Ids = list[i];
var data = IoCContainer.Get<ITaskDao>().SelectTaskNameAndNumber(taskCondition);
lock (_obj)
{
taskNames.Append(data);
}
});
}
System.Threading.Tasks.Task.WaitAll(theadTasks);