【发布时间】:2021-09-20 20:27:24
【问题描述】:
我正在使用 PySide6 和 QThread 编写一个 GUI 应用程序。我有两个不同的 QThread 对象,它们运行两个长时间运行的作业,它们不能重叠,所以如果一个线程正在运行,第二个必须等到第一个结束,如何获得这个?
我尝试写一个简单的代码示例:
from PySide6.QtCore import QThread
from MyJobs import LongJob
job_a = LongJob()
job_b = LongJob()
thread_a = QThread()
thread_b = QThread()
job_a.moveToThread(thread_a)
job_b.moveToThread(thread_b)
thread_a.start()
thread_b.start() # if thread_a is running, thread_b must wait until thread_a ends, then run and viceversa
【问题讨论】:
标签: python multithreading pyside pyside6