Is this use of a static queue thread-safe?

后端 未结 4 819
长情又很酷
长情又很酷 2020-12-10 14:16

The msdn documentation states that a static generic Queue is thread-safe. Does this mean that the following code is thread-safe? In other words, is there a problem when a th

4条回答
  •  攒了一身酷
    2020-12-10 14:46

    Yes, you have to lock just as MSDN says

    To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

提交回复
热议问题