Knowledge Base

How to Use _beginthreadex() and _endthreadex()

PSS ID Number: Q132078

Article Last Modified on 01-28-2002


The information in this article applies to:


Summary

This article shows by example how to use the thread handle returned by _beginthreadex() with the synchronization API WaitForSingleObject() in multithreaded applications.

When developing a multithreaded Win32-based application with Visual C++, you need to use the CRT thread functions to create any threads that call CRT functions. To create and terminate threads, use either _beginthread() and _endthread() or _beginthreadex() and _endthreadex(). If you use the Win32 APIs CreateThread() and EndThread() instead, some of the CRT functions used in the thread will not work. You need to use the CRT functions to both create and end the threads or you lose the memory that the CRT allocates for the thread.

Keywords: kbcode kbProgramming kbCRT kbVC200 kbVC210 kbVC220 kbVC400 kbVC500 kbVC600
Issue Type: kbhowto
Technology: kbVCsearch kbAudDeveloper kbCRT