_Thread_local storage class specifier in C?

五迷三道 提交于 2019-12-02 01:28:48

问题


I read a note in the book C How to Program 7th about some new standard C storage class named _Thread_local:

The new C standard adds storage class specifier _Thread_local, which is beyond this book's scope.

I looked for it in Google and here but nothing show up. Could someone please provide me some link about it?


回答1:


Variables marked with _Thread_local are given "thread" storage duration -- that is, they are allocated when a thread begins, and deallocated when the thread ends. Such variables are "local" to the thread, since every thread has its own copy of the variable. This is in contrast to static storage duration (one instance of the variable for the entire program). See http://en.cppreference.com/w/c/language/storage_class_specifiers for more details.



来源:https://stackoverflow.com/questions/14289634/thread-local-storage-class-specifier-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!