私は8つのコアを扱うために異なるスレッドを作成しようとしています。しかし、私はコードが8つのスレッドを作成し、私のMacOS上で100%の周りのみを使用して参照してください。 なぜですか?Pythonマルチスレッドは単一のCPUでしか動作しません
def runner(i):
# do random stuff
for a in range(0,1000000):
i+=1
5000/34 * i
i + 400
i/20000
i * 24440
i+=1
5000/34 * i
i + 400
i/20000
q = queue.Queue()
threads = list()
for x in range(0,80):
th = threading.Thread(target=runner,args=(x,))
threads.append(th)
for th in threads:
th.start()
for th in threads:
th.join()
https://stackoverflow.com/questions/3044580/multiprocessing-vs-threading-pythonとhttps://stackoverflow.com/questions/18114285/python-what-are-the-differences-between-theも参照してください。 -threading-and-multiprocessing-modul –