gpt4 book ai didi

c++11 - std::thread::id 跨进程是否唯一?

转载 作者:行者123 更新时间:2023-12-02 22:39:10 25 4
gpt4 key购买 nike

根据我的经验,结果似乎是

std::this_thread::get_id()

跨进程是唯一的:进程之间的 id 不同。

这是由标准保证的吗?

最佳答案

std::thread 是在支持 pthreads 的环境中在 pthreads 之上实现的。所以它变得没有(可移植)保证。

来自pthread_self手册:

Thread IDs are guaranteed to be unique only within a process. A
thread ID may be reused after a terminated thread has been joined, or a detached thread has terminated.

关于c++11 - std::thread::id 跨进程是否唯一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32824491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com