_unadopt_thread
process.h:インデックス への移動
ヘッダーファイル
process.h
カテゴリ
プロセス制御ルーチン
プロトタイプ
void _unadopt_thread(_PTHREAD_ADOPTION_DATA thd);
説明
前の _adopt_thread の呼び出しに関連付けられている RTL スレッド固有のデータを解放します。
戻り値
なし。
コード例
#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;
}
移植性
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |