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?
There are some examples on the Internet of people declaring their variables both volatile
Share
The two terms are not mutually exclusive.
volatileis 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.