From Appmethod Topics
Jump to: navigation, search

Go Up to process.h Index

Header File



Process Control Routines


void _endthread(void);


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.


#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");

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

  return 0;