# Slow Chat Archives > Slow Chat: Developing Multithreaded Applications >  The "volatile trick"

## Lindley

A while back I read this column:
http://www.drdobbs.com/cpp/184403766
which proposes "stealing" the volatile keyword to aid in establishing thread safety. This usage has nothing to do with the actual meaning of volatile; it just exploits the fact that it's part of the C++ type system.

Now, I came to the conclusion quickly that this was a bad idea. Neat, and I'd go with it in a second if there were a purpose-built keyword, but borrowing the volatile keyword for an unrelated use just seems to be asking for trouble; especially given the confusion which sometimes arises when Java programmers think that calling something volatile makes it thread safe (when it does nothing of the kind in C++).

I would like the opinions of the experts on this matter, however, because it's interesting enough as a concept.

----------


## Codeplug

FWIW, an old (and long) thread, with Mr. Alexandrescu and other industry experts - http://groups.google.com/group/comp....878c22d7775997

All other issues aside, my biggest gripe is the potential for confusion when putting the two together (volatile + multi-threading). Of course, MS giving multi-threaded semantics to volatile in MSVC v14/2005 didn't help the situation at all.

gg

----------


## ClayBreshears

I don't consider myself any kind of expert in this area, but I would recommend a different keyword.  For something that has been established for so long, additional usage will be confusing.  And, if there are any (unforeseen) side effects, recompilation of codes with the original use of "volatile" could break applications that have worked up to that point.

Why not something like "threadsafe" as the new keyword?  It's only got 2 more letters than "volatile." :-)

----------


## Lindley

^That'd be nice, but I think we have to stick with what the language provides now and in 1x.




> Of course, MS giving multi-threaded semantics to volatile in MSVC v14/2005 didn't help the situation at all.


Ack, really? Don't spread it around. Maybe no one will notice.....

----------

