Well yes, if you do it wrong you can shoot yourself in the foot.
ForNow wrote:the next thread that comes by can change its value
As far as I can see, the example you're looking at is not doing it wrong. The global variable is initialized once, in the place where the documentation says it should be initialized.
This seems to be a case of "if I stick a fork in my toaster whilst it's switched on, I can get an electric shock; therefore, all toasters are dangerous and should be banned".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."