python线程池示例

来源:互联网 发布:php 输出正三角形 编辑:程序博客网 时间:2024/05/18 00:04
import timeimport threadpooldef sayhello(str):    print "Hello ",str    time.sleep(2)name_list = ['xiaozi', 'aa', 'bb', 'cc']start_time = time.time()pool = threadpool.ThreadPool(10)requests = threadpool.makeRequests(sayhello, name_list)[pool.putRequest(req) for req in requests]pool.wait()print '%d second'% (time.time()-start_time)

原创粉丝点击