Quote Originally Posted by master5001 View Post
But even then you can tinker with your type declaration to make things thread safe.
You mean things like "volatile"? That doesn't make anything "safer" - it makes the compiler not optimize the read/write operations to the data item (and in later versions of MS compilers "lock" the data access for read-modify-write operations). It does not fix this:
Code:
char *somefunc(int x)
{
    static char buffer[100];
    sprintf(buffer, "%d", x);
    return buffer;
}
Call this function from two different functions with different values - then print the string - guess what: both threads will possibly print the same thing, and sometimes print "the wrong strings" value.

Volatile, or just about any other "compiler" solution will not solve this.

--
Mats