This is only true in general.
In general static methods are static because they are not dependant on nor do they access any instance defined data that another thread could also access. In general, the only variables they use are local variables, declared and scoped to the stack frame of that instance of the method. If they did, they could not be static. An Instance method, in contrast, does access some data element (property or field) of the instance.
If, otoh, a static method accesses a static property or field of the class, it is equally non-thread -safe.
There are four conditions needed for a race to be possible.
- The first condition is that there are memory locations that are accessible from more than one thread. Typically, these locations are global/static variables or are heap memory reachable from global/static variables.
- The second condition is that there is a property (often called an invariant), which is associated with these shared memory locations that must be true, or valid, for the program to function correctly. Typically, the property needs to hold true before an update occurs for the update to be correct.
- The third condition is that the invariant property does not hold during some part of the actual update. (It is transiently invalid or false during some portion of the processing).
- The fourth and final condition that must occur for a race to happen is that another thread accesses the memory while the invariant is broken, thereby causing inconsistent or incorrect behavior.