Python 官方文档:入门教程 => 点击学习
import threading import time def producer(): print(u"chef:等人买包子") event.wait() event.clear() print("开始
import threading
import time
def producer():
print(u"chef:等人买包子")
event.wait()
event.clear()
print("开始做包子")
time.sleep(3)
print("包子好了")
event.set()
def consumer():
print("zs:我去买包子")
event.set()
time.sleep(2)
print("等着包子做好")
event.wait()
print("Thinks")
event = threading.Event()
c1 = threading.Thread(target=consumer)
p1 = threading.Thread(target=producer)
p1.start()
c1.start()
--结束END--
本文标题: python中event事件应用举例
本文链接: https://lsjlt.com/news/191905.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0