#pragma omp threadprivate


The omp threadprivate directive makes the named file-scope, namespace-scope, or static block-scope variables private to a thread.


Read syntax diagramSkip visual syntax diagram                                 .-,------------.
                                 V              |
>>-#--pragma--omp threadprivate----(identifier)-+--------------><

where identifier is a file-scope, name space-scope or static block-scope variable.


Each copy of an omp threadprivate data variable is initialized once prior to first use of that copy. If an object is changed before being used to initialize a threadprivate data variable, behavior is unspecified.

A thread must not reference another thread's copy of an omp threadprivate data variable. References will always be to the master thread's copy of the data variable when executing serial and master regions of the program.

Use of the omp threadprivate directive is governed by the following points: