How to Create a Thread-Safe Generic List?

后端 未结 8 1215
借酒劲吻你
借酒劲吻你 2020-12-08 10:42

I have a Generic List as below

public static readonly List Customers = new List();

I\'m using the below met

8条回答
  •  悲哀的现实
    2020-12-08 11:07

    You will need to use locks in every place where the collection gets modified or iterated over.

    Either that or use one of the new thread-safe data structures, like ConcurrentBag.

提交回复
热议问题