标签:charm 加班 clear for def build main read builder
# project:pybuilder
# author:slx
# datetime:2019/2/20 3:19
# software: PyCharm
import threading
import time
event =threading.Event()
class Boss(threading.Thread):
def run(self):
print("Boss:今天大家加班到22:00")
event.set()
time.sleep(5)
print("Boss:大家可以下班了")
event.set()
class worker(threading.Thread):
def run(self):
event.wait()
print("Worker:哎,命苦啊....")
event.clear()
time.sleep(1)
event.wait()
time.sleep(1)
print("Yeah...")
if __name__ == ‘__main__‘:
worker_threads = []
for i in range(5):
worker_threads.append(worker())
for t in worker_threads:
t.start()
boss_threads = []
boss_threads.append(Boss())
for u in boss_threads:
u.start()
标签:charm 加班 clear for def build main read builder
原文地址:https://www.cnblogs.com/knowlearner/p/10404390.html