import queue, threading, time q = queue.Queue(maxsize=10) def producter(n): count = 1 while True: q.put(count) print('%s 生产了%s 骨头'%(n,count)) time.sleep(1) count += 1 def consumer(n): while True: print('%s 获得了 %s 骨头'%(n,q.get())) time.sleep(1) p = threading.Thread(target=producter, args=('alex',)) c = threading.Thread(target=consumer, args=('陈荣华',)) c1 = threading.Thread(target=consumer, args=('王森', )) p.start() c.start() c1.start()