_endthreadex
process.h:インデックス への移動
ヘッダーファイル
process.h
カテゴリ
プロセス制御ルーチン
プロトタイプ
void _endthreadex(unsigned thread_retval);
説明
ExitThread API を呼び出して現在のスレッドの実行を終了しますが,ハンドルは閉じません。スレッドは,_beginthreadex の呼び出しによって事前に作成されている必要があります。スレッド関数が終了すると,ランタイムライブラリは自動的に _endthreadex を呼び出します。_endthreadex は,スレッド関数の戻り値を thread_retval で受け取り,それを Win32 ExitThread API に渡します。
メモ: メモ:_endthread() と同じ操作を実行しますが,スレッドハンドルは閉じません。
戻り値
なし。
コード例
#include <process.h>
#include <windows.h>
unsigned int _stdcall thread_func(void*)
{
/* Print a string and close the thread from inside */
printf("Running on another thread!\n");
_endthreadex(0);
}
int _tmain(int argc, _TCHAR* argv[])
{
/* Start the thread and wait */
unsigned int threadId;
_beginthreadex(NULL, 4096, thread_func, NULL, 0, &threadId);
Sleep(100);
return 0;
}