_unadopt_thread
Remonter à process.h - Index
Header File
process.h
Category
Process Control Routines
Prototype
void _unadopt_thread(_PTHREAD_ADOPTION_DATA thd);
Description
Frees the RTL thread-specific data associated with a previous call to _adopt_thread.
Return Value
None.
Example
#include <process.h> #include <windows.h> void adopted_thread(void*) { printf("Running in a RTL-managed thread!\n"); } unsigned long __stdcall winapi_thread(void*) { /* This code runs on another thread, created by CreateThread Win32 API. _adopt_thread is used to continue the execution in the routine that is RTL managed (in the same thread context). */ printf("Running in a simple thread! Adopting ...\n"); _PTHREAD_ADOPTION_DATA data = _adopt_thread(adopted_thread, NULL, false); /* Un-adopt the thread and release it's resources */ printf("Back to OS thread! Release adoption ...\n"); _unadopt_thread(data); } int _tmain(int argc, _TCHAR* argv[]) { /* Create a thread using OS APIs, thus RTL-unmanaged */ unsigned long threadId; CreateThread(NULL, 0, winapi_thread, NULL, 0, &threadId); Sleep(100); return 0; }
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |