Qt: Using multithreading to end times wrong questions

Source: Internet
Author: User

After multiple threads are created, an error pops up if the resource is not reclaimed before the program is closed.

1. In general, a direct call to the thread's Quit () method ends the process and reclaims memory.

2. If the program is running in the process of accidental termination, such as forced shutdown, the above error will occur. Therefore, the following processing is required:

Rewrite the closeevent to reclaim the memory before closing the program. The methods used are

Thread->terminate (); thread->wait ();
具体实现为:
Closeevent (qcloseevent *ev)    {        qdebug ()<<"before wait";        Thread-Terminate ();        Thread-and-wait ();        Qdebug ()<<"afterwait";        Qmainwindow::closeevent (EV);    }

Qt: Using multithreading to end times wrong questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.