List.Add() thread safety

后端 未结 9 2259
庸人自扰
庸人自扰 2020-11-29 07:57

I understand that in general a List is not thread safe, however is there anything wrong with simply adding items into a list if the threads never perform any other operation

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 08:16

    Even adding elements on different threads is not thread safe.

    In C# 4.0 there are concurrent collections (see http://jiezhu0815.blogspot.com/2010/08/c-40-feature-1-concurrent-collections.html).

提交回复
热议问题