Thread safety is applicable in the context of multi-threaded programs.
You can't be sure about that, if it is a global or static variable, because it may be accessed by more than one
thread at a same time with different purpose(assume read and write).
Which may cause problem.
And If it is a local varible, than it is totally threadsafe because each thread has its own private copy.
Yes single assignment is not a threadsafe.
Lets understand this with example:
Lets assume a = 6 and b = 10
a = b //This statement is got divided into different statement in assembly language like this:
R1 = b ----> step 1 (R1 is a register insde the CPU, 1st b has to be stored in R1)
a = R1 ----> step 2 (Then R1 value whill be assign to a)
So before completion of the above steps (i.e step 1 and step 2), if another process try to access the value of a it may get the some other value.
In the aboe example: if process2 want to access the value of a while process1 is in step 1 i.e (R1 = b)
So the process2 will get value of a as 6, but we are expecting it to be 7.