Reputation: 5188
There are some examples on the Internet of people declaring their variables both volatile
and __thread
. I think it's a mistake because __thread
implies that there's a copy for each thread, so with volatile
the "best" you can do is disable caching of such variable, for some obscure reasons. Am I missing something?
Upvotes: 1
Views: 262
Reputation: 39797
The two terms are not mutually exclusive. volatile
is not only used in matters of multi-threading, it's used for any situation the variable might change without the current code block being aware -- such as callback functions, or signal handlers.
Upvotes: 4