Unix to Windows Porting Dictionary for HPC

Links

Function List

pthread_cancel


Unix

header file: pthread.h

int pthread_cancel(pthread_t thread);

Windows

header file: Windows.h

BOOL WINAPI TerminateThread(
  __inout  HANDLE hThread,
  __in     DWORD dwExitCode
);
      

Purpose

The pthread_cancel function is a request to terminate the execution of the thread pointed to by thread.

Discussion

The Windows equivalent function will also terminate the called for thread, but any DLLs associated with the terminated thread are not notified. The thread’s stack is deleted. As pointed out in the MSDN documentation, this is an extremely dangerous call unless you know exactly what the thread to be terminated is doing at the time of termination.

If the call is successful, the return value will be NON-zero. To get more information you can call GetLastError.

Example of Use in Windows

    

More Information

    blog comments powered by Disqus