我正在尝试练习多线程。我从网上找到了一个教程。
from multiprocessing.dummy import Pool
def calcPi_thread(nuFutures,tries,n):
ts = time.time()
#define the Pool
p = Pool(n)
#use multi-thread to run function 'test'
result = p.map(test,[tries]*nbFutures)
ret = 4.*sum(result)/float(nbFutures*tries)
span = time.time()-ts
print "Time Spend for Mutli-Thread(Thread=" + str(n) + ") is " + str(span)
return ret
当我运行上面的代码时,它说“没有模块名为dummy'”。 multiprocessing.dummy是Python 2.7.6中的默认模块?我是否需要手动安装此模块?