Static variable: thread is not secure.
The variable with the static keyword can only be placed in a class and cannot be placed in a method.
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.
Variables that do not have a static keyword can only be placed in a class and cannot be placed in a method.
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.
A local variable is a variable within a method.
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.
Static variables, instance variables, local variables for Java thread safety issues