User Tools

Site Tools


c:c_threads:thread_local_storage_thread_local

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:c_threads:thread_local_storage_thread_local [2021/03/05 16:07] – created peterc:c_threads:thread_local_storage_thread_local [2021/03/05 16:10] (current) peter
Line 48: Line 48:
 } }
 </code> </code>
 +
 +returns:
 +
 +<code>
 +Value of globalVar in thread 140620033623808 is 5
 +Value of globalVar in thread 140620025231104 is 20
 +Value of globalVar in MAIN thread is 1
 +</code>
 +
 +----
 +
 +If globalVar was not declared **thread_local** then the returned result would be:
 +
 +<code>
 +Value of globalVar in thread 140275965699840 is 20
 +Value of globalVar in thread 140275957307136 is 20
 +Value of globalVar in MAIN thread is 20
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  If the global value was not thread local, the change made by each thread will be persisted outside the thread.
 +</WRAP>
 +
c/c_threads/thread_local_storage_thread_local.1614960426.txt.gz · Last modified: 2021/03/05 16:07 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki