Thread Specific Data vs Thread Local Storage

后端 未结 2 2010
耶瑟儿~
耶瑟儿~ 2020-12-14 21:12

I\'ve read Kerrisk\'s The Linux Programming Interface: A Linux and UNIX System Programming Handbook, Chapter 31 on Threads. The chapter include Thread Specific Data (Section

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 21:12

    The pthread interfaces are POSIX standard, so they are more portable. Use them if you intend to use the code on something besides a linux system. On the other hand, if you are strictly on gcc/linux, then the __thread mechanism is certainly easier to use. Just be aware that it is a gcc specific extension, and not supported on all platforms.

提交回复
热议问题