c++ - 在 Windows 中使用 PTHREAD 互斥?

标签 c++ multithreading pthreads

当线程终止执行调用 pthread_exit(NULL) 时,它的互斥体是否空闲?

最佳答案

来自 pthread_exit 的文档:

The pthread_exit() function shall terminate the calling thread and make the value value_ptr available to any successful join with the terminating thread. Any cancellation cleanup handlers that have been pushed and not yet popped shall be popped in the reverse order that they were pushed and then executed. After all cancellation cleanup handlers have been executed, if the thread has any thread-specific data, appropriate destructor functions shall be called in an unspecified order. Thread termination does not release any application visible process resources, including, but not limited to, mutexes and file descriptors, nor does it perform any process-level cleanup actions, including, but not limited to, calling any atexit() routines that may exist.

所以不,你的互斥锁不会被释放。

关于c++ - 在 Windows 中使用 PTHREAD 互斥?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23194282/

相关文章:

c++ - vector 排序和更改数据

python - 多线程 Python 中的信号处理

c - 向 C 中的 pthreads 发送和捕获信号

c - 从当前线程中找出事件线程的状态。 (稳健互斥体的实现)

C++ 没有已知参数 1 从 ‘Node*’ 到 ‘Node*&’ 的转换

c++ - Qt Signal 是发射器,但信号似乎没有触发

java - Java 中 ThreadLocal 的真实用法

c cygwin- abored(核心已转储)

C pthread 和 struct 问题

c++ - 并行快速排序 : recursion using Boost Bind?