算命縖子'blog

导航

2018年4月18日 #

Python 限制线程的最大数量(Semaphore)

摘要: import threadingimport timesem = threading.Semaphore(4) # 限制线程的最大数量为4个 def gothread(): with sem: # 锁定线程的最大数量 for i in range(8): print(threading.current_thread().name, i) ... 阅读全文

posted @ 2018-04-18 23:09 算命縖子 阅读(1669) 评论(0) 推荐(0) 编辑