为什么python线程占用我所有的核心

时间:2018-03-16 09:25:30

标签: python multithreading concurrency

我在Ubuntu 14.04中编写了以下多个线程代码

import threading

def worker():
    """thread worker function"""
    while True:
        continue
    return

threads = []
for i in range(4):
    t = threading.Thread(target=worker)
    threads.append(t)
    t.start()
~              

这是图像:       CPU load image

一个包含四个线程的进程占用了四个CPU核心。为什么呢?

0 个答案:

没有答案