Re: Need to use "volatile" for accessing variables between threads?
On Jul 27, 2:58 pm, Virchanza <virt...@lavabit.com> wrote:
Volatile is intended to be used where a variable's value can
mysteriously change outside of the normal flow of code.
I'm still not sure whether "a separate thread" qualifies as
being mysterious enough.
It's mysterious enough, in that sense. The point is that your
synchronization requests have already specified that such
changes can occur, outside the protected region. (In fact,
many compilers, such as Sun CC, g++ and VC++, don't implement
sufficient synchronization for volatile to be usable for much of
anything. Such compilers are arguably broken, but you'll almost
certainly have to use them.)
Some people are telling me I need volatile. Others are telling
me I don't need volatile. I don't know who to believe.
Is it even possible to get an answer to this question, or is
it simply "undefined"?
You've been given the answer.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34