When writing a lot of C/C++ code over the last few years I ran into this. As retep said, it's thread-safe, it's just that your results aren't. This is contrast to the process models on other operating systems where if you manipulate the environment it acts sort of like container/process->threads->userland magic tiering; Windows treats threads almost like a process (somewhat arbitrarily). The model works for some things, and has drawbacks for others.