2021
07-08
07-08
Python 线程池模块之多线程操作代码
1、线程池模块引入fromconcurrent.futuresimportThreadPoolExecutor2、使用线程池一个简单的线程池使用案例fromconcurrent.futuresimportThreadPoolExecutorimporttimepool=ThreadPoolExecutor(10,'Python')deffun():time.sleep(1)print(1,end='')if__name__=='__main__':#列表推导式[pool.submit(fun)foriinrange(20)ifTrue]fromconcurrent.futuresimportThreadPoolExecutorimporttime...
继续阅读 >