Unix to Windows Porting Dictionary for HPC

RSS

Links

Function List

pthread_exit


Unix

header file: pthread.h

void pthread_exit(void *value_ptr);

Windows

header file: Windows.h

void WINAPI ExitThread(__in DWORD dwExitCode);

Purpose

The pthread_exit function is used to terminate a thread. The value is returned to any successfully joining thread.

Discussion

The Windows equivalent function is effectively the same as the POSIX version. This deallocates the stack and cancels all pending I/O.

Example of Use in Windows

#include <stdio.h>
#include <windows.h>

DWORD WINAPI newThreadFunc(LPVOIDarg) 
{ 
printf("Hello World from the new thread\n"); 
return 0; 
}

main() 
{
printf("Hello World from the main program\n"); 
HANDLE hThread= CreateThread(NULL,0,newThreadFunc,NULL,0,NULL);
return 0;
}
    
blog comments powered by Disqus
Valid HTML 4.01 Transitional Valid CSS!