python Queue.queue获取并放置线程安全吗?

时间:2022-09-06 21:04:05

http://docs.python.org/2/library/queue.html#Queue.Queue.put

It seems a naive question, but I didn't find the answer on the docs nor with Googling, so are these methods thread safe ? I assume so otherwise there is no point in this queue.

这似乎是一个天真的问题,但我没有找到文档的答案,也没有使用谷歌搜索,所以这些方法线程安全吗?我假设这样,否则这个队列中没有任何意义。

1 个解决方案

#1


31  

See 8.10 Queue — A synchronized queue class (at the top)

请参见8.10队列 - 同步队列类(在顶部)

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.

Queue模块实现多生产者,多消费者队列。当必须在多个线程之间安全地交换信息时,它在线程编程中特别有用。

#1


31  

See 8.10 Queue — A synchronized queue class (at the top)

请参见8.10队列 - 同步队列类(在顶部)

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.

Queue模块实现多生产者,多消费者队列。当必须在多个线程之间安全地交换信息时,它在线程编程中特别有用。