Hello arangasoft

Seen you here after quite sometime and something about the volatile keyword.

If you using a multithreaded program and your one thread is something like
Code:
if (myVar ==  NULL)
{
  SomeFunction();
  if (myVar == NULL)
    ...
}
Now consider the situation that SomeFunction is a very long process and in some cases the some other thread can edit the value of myVar then for second condition testing you are in trouble as compiler in process of optimization may not test the condition again and may skip it as always true but if you declare the myVar as volatile then it signals the compiler that its just not the one thread that operates on the variable and so it will not cache the second condition.

Code:
volatile MyClass* myVar;
Thanks and hope it helps
Shabbir Bhimani