Hay*_*tuk 21 c c++ static multithreading thread-safety
如何定义不在不同线程之间共享的本地静态变量(在函数调用之间保持其值)?
我正在寻找C和C++的答案
Rom*_*Rom 12
在Windows上使用Windows API:TlsAlloc()/TlsSetValue()/ TlsGetValue()
在Windows上使用编译器内在:使用_declspec(线程)
在Linux(其他POSIX ???):get_thread_area()和相关
只需在函数中使用static和__thread即可.
例:
int test(void)
{
        static __thread a;
        return a++;
}
| 归档时间: | 
 | 
| 查看次数: | 15335 次 | 
| 最近记录: |