擅长:python、mysql、java
<p><a href="http://pymotw.com/2/Queue/#using-queues-with-threads" rel="nofollow noreferrer">Use a Queue.Queue</a>将值从读线程传递到单个写入线程。将队列实例传递给每个<code>data_collector.main</code>函数。它们都可以调用队列的<code>put</code>方法。在</p>
<p>同时,<code>write_to_log_file.main</code>也应该传递给同一个队列实例,它可以调用队列的<code>get</code>方法。
当项目从队列中拉出时,可以将它们添加到<code>dict</code>。在</p>
<p>另见:Alex Martelli,关于为什么<a href="https://stackoverflow.com/a/1192114/190597">Queue.Queue is the secret sauce of CPython multithreading</a>。在</p>