Lorenzo Pistone
Lorenzo Pistone

Reputation: 5188

volatile __thread, pointless?

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

Answers (1)

mah
mah

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

Related Questions