如何暂停主线程直到完成一组并行线程的执行?

2024-10-08 19:31:40 发布

您现在位置:Python中文网/ 问答频道 /正文

首先,我是python多线程的新手。我有一个程序,检测手的照片集使用多个并行线程和检测后,主程序做一些功能的基础上,手检测图像。函数在主线程上。但是现在这两个函数和手检测线程都是并行运行的。我需要暂停主线程,直到完成手检测线程的执行。对不起,我的语言错误

#Thread creation function

def callThreads(self, imageLst):
        global taskLock, tasks
        for tid in range(1, 10, 1):  ## 1,11,1
            thread = handdetect.detectHandThread(imageLst, tid, 'thread_{}'.format(tid), tasks, taskLock,
                                                 obj_detection_graph_queue, obj_detLock)
            thread.start()
            threads.append(thread)
            print("[INFO] Thread {} created and added to the pool...".format(tid))
# main() function of the programme
..............
self.callThreads(filenames)

Some functions()
............




Tags: the函数selfobjformatfunctionthread主线

热门问题