0
在另一大類:QThreads在運行兩次時如何工作?
self.workerThread = WorkerThread()
def startThread():
self.workerThread.setGameName("pizza")
self.workerThread.start()
的QThread類:
class WorkerThread(QThread):
def _init_(self, parent = None):
super(WorkerThread, self)._init_(parent)
self.gameName = ""
def setGameName(self, currGameName):
self.gameName = currGameName
def run(self):
#do something with self.gameName
在主:
startThread()
startThread()
當我運行它,它使用從第一個呼叫,而不是第二的gameName 。函數調用看起來是交錯的。有人可以解釋Qthread的工作原理嗎?如何爲startThread()的每個單獨函數調用設置一個gameName?