Q:

How does variable scope affect multithreading race conditions?

Are instance variables also shared just like static variables? Does this mean that race conditions happen due to static and instance variables only?

A:

Doesn't matter if the shared resource is a shared object, public instance variables or static content, all of these might cause race-condition (that is, unless the shared resource is immutable ).

A:

Yes instance variables are shared as well, if multiple threads have access to the instance then there may be a need to protect against stale reads or multi-part writes that can corrupt the object's state.
Additionally, accessing external resources such as files on the file system can cause race conditions.

