import  time

def consumer(name):
    print('我是[%s],我准备开始吃包子了' %name)
    while True:
        baozi=yield
        time.sleep(1)
        print('%s 很开心的把【%s】吃掉了' %(name,baozi))

def producter():
    c1=consumer('raitorei')
    c2=consumer('ray')
    c1.__next__()
    c2.__next__()
    for i in range(10):
        time.sleep(1)
        c1.send('包子 %s' %i)
        c2.send('包子 %s' %i)
producter()

 

posted on 2019-11-28 20:10  月零Ray  阅读(123)  评论(0编辑  收藏  举报