# Author:XiangLiang
import threading,time
import queue

q = queue.Queue(maxsize=10)
def Producer(name):
count = 1
while True:
q.put("骨头 %s" %count)
print("生产了骨头",count)
count += 1
time.sleep(0.1)

def Consumer(name):
while True:
print("%s 取到 %s 并且吃了" %(name,q.get()))
time.sleep(1)

p = threading.Thread(target=Producer,args=("ZS",))
c = threading.Thread(target=Consumer,args=("XiaoHe",))
c1 = threading.Thread(target=Consumer,args=("HuZi",))

p.start()
c.start()
c1.start()

相关文章:

  • 2021-06-03
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-08-02
  • 2021-10-12
相关资源
相似解决方案