About creating a thread

Source: Internet
Author: User

The createthread function is a Windows API.

It does not initialize a thread when it is created.

When some non-reentrant functions are used, the thread allocates thread-related space to save some global variables. When the thread exits, the space will not be released, resulting in Memory leakage.

 

The _ beginthreadex function is a CRT function.

Some initialization actions will be performed when the thread is created. During the return of the thread function, _ endthreadex will be automatically called to automatically release the memory.

Directly calling _ endthreadex will cause local variables in the thread function to fail to be destructed.

 

The afxbeginthread function is mainly used in the MFC program.

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.