c++ - The correct way to exit a thread in Qt with finished signal and make clean_up -
I have an application that has several threads. When I close my main app and call thread destructors, then I need to get out of threads.
Class Thread: Public Qtyth {thread (); Run () {while (1) {// work}} ~ thread () {// want to clear}}; Class my_app: Public QCoreapplication {my_app () {Thread th1; Connect (& Th1, sign (end ()), & amp; Th1, deleteLater ()); Connect (& Th1, hint (end ()), & amp; Th1, drop ()); }}; // and my th1 thread runs in while. So I know that this problem is that it runs on time and never emits the finished signal / how can it be obtained?
-
- Provide some thread secure in the worker loop The flag, which will indicate that the worker should end his job.
- Before terminating the application, you should call to make sure that the thread will be completely exhausted before the end of the application.
Comments
Post a Comment