Suspension of QT and boost threads

Source: Internet
Author: User

A while ago, I wrote a numberProgram. A total of two functions are implemented: 1. start/stop of running; 2. Start computing again. The START/pause part must be suspended to find the prime number of threads. But I read the document several times and found that there was no function to suspend the thread ......

After searching for a long time, I found that the POSIX thread model did not include the suspension function. If a ready-made thread is suspended, the resources occupied by the thread cannot be released. As long as the thread is suspended, the resources it occupies remain in the occupied State. Therefore, the POSIX model handed this right to the operating system designer.

The solution is to use the lock.

Boost and QT both use the POSIX thread model, so they do not have to suspend functions.

Add on:

After practice, we found that qmutex of QT is not allowed in the thread To unlock the qmutex object locked in thread a in thread B. So with my current knowledge, there is no method for suspending threads in QT. You can only determine whether to allow running at each running time.

The boost lock is acceptable, but its actual running status can only be described as "weird ......

The specific solution is still in practice!

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.