_endthread

De RAD Studio
Aller à : navigation, rechercher

Remonter à process.h - Index


Header File

process.h

Category

Process Control Routines

Prototype

void _endthread(void);

Description

Terminates execution of a thread.

The _endthread function terminates the currently executing thread by closing the thread handle and calling the ExitThread API. The thread must have been started by an earlier call to _beginthread or _beginthreadNT.. _endthread is called automatically by the runtime library when your thread function terminates.

This function is available in the multithread libraries; it is not in the single-threaded libraries.

Return Value

The function does not return a value.

Example

#include <process.h>
#include <windows.h>
void thread_func(void*)
{
  /* Print a string and close the thread from inside */
  printf("Running on another thread!\n");
  _endthread();
}

int _tmain(int argc, _TCHAR* argv[])
{
  /* Start the thread and wait */
  _beginthread(thread_func, 4096, NULL);
  Sleep(100);

  return 0;
}