Is List thread-safe for reading?

后端 未结 4 1021
遥遥无期
遥遥无期 2020-12-17 08:08

Is the following pseudocode thread-safe ?

IList dataList = SomeNhibernateRepository.GetData();

Parallel.For(..i..)
{
    foreach(var item in dataLi         


        
4条回答
  •  猫巷女王i
    2020-12-17 08:29

    If whay you say is correct then I would say so. But what you say or think may not what happen in reality. How can you say in code what you have said. How to enforce the constraint that List is never modified?

提交回复
热议问题