Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Thread storage duration

      From cppreference.com
      <c‎ |language
       
       
       

      An object whose identifier is declared with the storage-class specifier_Thread_local(since C11) has thread storage duration. Its lifetime is the entire execution of the thread for which it is created, and its stored value is initialized when the thread is started. There is a distinct object per thread, and use of the declared name in an expression refers to the object associated with the thread evaluating the expression. The result of attempting to indirectly access an object with thread storage duration from a thread other than the one with which the object is associated is implementation-defined.

      [edit]Example

      Run this code
      constdouble PI=3.14159;/* const variable is global to all threads  */_Thread_localunsignedint seed;/* seed is a thread-specific variable       */ int main(void){return0;}

      Possible output:

      (none)
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/language/thread_storage_duration&oldid=72909"

      [8]ページ先頭

      ©2009-2026 Movatter.jp