python线程池示例

import time
import threadpool
def 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)

上一篇:一个监控脚本带来的Python实践和学习


下一篇:python进程注入shellcode