參:https://www.qtcentre.org/threads/6548-Multiple-start()-on-same-QThread-Object
Hi all,
can I run multiple start() method on same QThread object ?
Simple example follows:
Qt Code:
int main(int argc, char *argv[]){ threadHandler *TH=new threadHandler(); TH.start() TH.start() return app.exec(); }
To copy to clipboard, switch view to plain text mode
This code executes the two run() methods as two serial executions.
Is this correct? Do you have experience in this?
Thanks,
Michele
Re: Multiple start() on same QThread Object
2. Thread: 同一個Thread只能呼叫start()一次,Thread執行完後,不能再次呼叫start(),否則會有錯。可能的解法是在執行start()前,先建立Thread class object:
process = Thread(target=crawl, args=[urls[ii], result, ii])- process.start()
you should note that you cannot restart a thread once it has finished execution: you have to recreate the thread object for it to be started again.
沒有留言:
張貼留言