import threading
from queue import Queue
q = Queue()
def porducer(i):
"""
生产者
:param i:
:return:
"""
print('产品:', i)
info = {'to': '269', 'text': 'hello', 'subject': '好友请求'}
q.put(info)
def consumer():
"""
消费者
:return:
"""
print('消费者去队列取了任务')
info = q.get()
print(info)
for i in range(10):
t = threading.Thread(target=porducer, args=(i,))
t.start()
for i in range(5):
t = threading.Thread(target=consumer)
t.start()