Are Python built-in containers thread-safe?

后端 未结 4 1298
感情败类
感情败类 2020-12-01 09:18

I would like to know if the Python built-in containers (list, vector, set...) are thread-safe? Or do I need to implement a locking/unlocking environment for my shared variab

4条回答
  •  不知归路
    2020-12-01 09:24

    The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics.

    https://docs.python.org/3/library/queue.html

提交回复
热议问题