__thread

From Appmethod Topics
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Keyword Extensions

Description

The __thread keyword is used in multithread programs to preserve a unique copy of global and static class variables. Each program thread maintains a private copy of a __thread variable for each thread.

The syntax is Type __thread variable__name. For example

 int __thread x;

This statement declares an integer type variable that will be global but private to each thread in the program in which the statement occurs.

See also