Hi All,

I have this bit of code like this:

shared bool varInitialized = false;
bool initVar() {
   bool ret;
   synchronized { ret = varInitialized;}
   return ret;
}

I know there are atomics and I am using them but I am curious about the above code. It compiles but I have no idea how safe it is.

Reading TDPL I got the impression synchronized works only for entire classes. If so why does the above compile and is it thread safe?

Thanks for any help

Cheers,
Stewart

Reply via email to