小编Lad*_*ady的帖子

无法在Python中创建新线程

import threading

threads = []
for n in range(0, 60000):
    t = threading.Thread(target=function,args=(x, n))
    t.start()
    threads.append(t)
for t in threads:
    t.join()
Run Code Online (Sandbox Code Playgroud)

它在我的笔记本电脑上的范围高达800,但是如果我将范围增加到800以上,我就会收到错误can't create new thread.

如何控制线程创建的数量或任何其他方式使其像超时一样工作?我尝试使用threading.BoundedSemaphore功能,但似乎没有正常工作.

python multithreading python-multithreading

6
推荐指数
1
解决办法
6762
查看次数