Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading Python线程功能-如何实现?_Multithreading_Python 2.7 - Fatal编程技术网

Multithreading Python线程功能-如何实现?

Multithreading Python线程功能-如何实现?,multithreading,python-2.7,Multithreading,Python 2.7,我是Python线程的新手,我已经对此进行了研究。我想实现以下用伪代码编写的功能: while True: while(file size < 1 GB): sleep for 1 minute process(file) file = next file 为True时: 而(文件大小

我是Python线程的新手,我已经对此进行了研究。我想实现以下用伪代码编写的功能:

while True:
    while(file size < 1 GB):
        sleep for 1 minute
    process(file)
    file = next file
为True时:
而(文件大小<1 GB):
睡一分钟
进程(文件)
file=下一个文件
我希望process()函数是一个守护进程线程。下一次到达代码中的第4行(下一个文件为1GB)时,如果前一个线程正在运行,则应该创建一个新线程。这样的线程最多为3个,它们一个接一个地循环。任何时候都至少有2个线程空闲。因此,基本上,只要代码到达第4行,就应该调用任何一个空闲线程来完成这项工作

守护进程线程和线程队列是我需要看的东西吗?还是有其他办法解决这个问题