pthread_tryjoin_np?有没有Windows版本

pthread_tryjoin_np? Is there a Windows version of it?

本文关键字:Windows 版本 有没有 np tryjoin pthread      更新时间:2023-10-16

pthread_tryjoin_np 是不可移植的。有某种Windows版本吗?创建线程但不阻塞?

在Windows中,CreateThread给你一个HANDLE,你可以等待它来学习线程何时退出 - 这类似于posix平台上的pthread_tryjoin。

要等待超时,或轮询线程退出,这是pthread_tryjoin_np通常执行的操作(_np代表不可移植,因此该函数可能存在各种变体),您可以使用 WaitForSingleObject 和线程的句柄。

虽然不在当前的官方实现中(截至 2012 年 5 月 27 日的 2.9.1),pthread_tryjoin()在当前的后备箱中 https://sourceware.org/cgi-bin/cvsweb.cgi/pthreads/?cvsroot=pthreads-win32

请参阅此处的更新日志:https://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/pthreads/ChangeLog?rev=1.370&content-type=text/plain&cvsroot=pthreads-win32

你可以像这样使用 CVS 拉取源代码

cvs -d :pserver:anonymous@sourceware.org:/cvs/pthreads-win32 checkout pthreads

他们应该使用VC Express或MinGW gcc进行构建。