信号量事件定时器
信号量 Semaphore
from threading import Thread, Semaphore
import threading
import time
def func():
sm.acquire()
print('%s gets sm' % threading.current_thread().getName())
time.sleep(3)
sm.release()
if __name__ == '__main__':
sm = Semaphore(5)
for i in range(23):
t = Thread(target=func)
t.start()事件 Event
定时器 Timer
Last updated