标签:线程 == 卡住 join threading eve 设定 pre worker
import threading
import time
class Boss(threading.Thread):
def run(self):
print("boss: 今晚加班到12.00")
print(event.isSet())
event.set()
time.sleep(5)
print("时间到了,下班了")
print(event.isSet())
event.set()
class Worker(threading.Thread):
def run(self):
event.wait()
print("Worker:惨 啊")
time.sleep(1)
event.clear()
event.wait()
print("yes")
if __name__ == '__main__':
event = threading.Event()
threads = []
for i in range(5):
threads.append(Worker())
threads.append(Boss())
for t in threads:
t.start()
for t in threads:
t.join()
标签:线程 == 卡住 join threading eve 设定 pre worker
原文地址:https://www.cnblogs.com/hyxk/p/11287738.html