[英]Is thread_local initialization performed on each thread, in the context of that thread
如果我有一个带有动态初始值设定项的thread_local
存储类的变量,它可能会被初始化多次:至少对每个使用它的线程进行一次。
这种初始化是在新创建的线程的上下文中发生的,还是可能发生在不同的线程上?
具体来说,以下任一项是否有效:
thread_local int tid1 = pthread_self();
thread_local int tid2 = syscall(SYS_gettid);
...从某种意义上说tid1
和tid2
获得当前线程的正确 ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.