Static variable: thread is not secure.
A static variable is a class variable, located in the method area, shared for all objects, shares a portion of memory, and once the static variable is modified, the other objects are visible to the modification, so the thread is not secure.
Instance variables: Singleton mode (only one object instance exists) thread is not secure, not singleton thread safe.
Instance variables are private to the object instance, allocated in the heap of the virtual machine, if there is only one instance of this object in the system, in multi-threaded environment, "like" static variable, after being modified by a thread, other threads are visible to the modification, so the thread is not safe, if each thread executes in a different object, The modification of the instance variable between the object and the object will not affect each other, so thread safety.
Local variables: thread safety.
Each thread executes a local variable in the working memory of its own stack frame and is not shared between threads, so there is no thread-safety issue.
Thread safety of variables in Java