Are lists thread-safe?

后端 未结 4 1960
星月不相逢
星月不相逢 2020-11-22 16:17

I notice that it is often suggested to use queues with multiple threads, instead of lists and .pop(). Is this because lists are not thread-safe, or for some oth

4条回答
  •  清酒与你
    2020-11-22 16:50

    To clarify a point in Thomas' excellent answer, it should be mentioned that append() is thread safe.

    This is because there is no concern that data being read will be in the same place once we go to write to it. The append() operation does not read data, it only writes data to the list.

提交回复
热议问题