Local variables: in the stack.
Local variables will never have a security problem. Because local variables are not shared. (One thread, one stack.) Local variables: in the stack. So local variables are never shared.
Instance variables: in the heap.
The instance variable is in the heap, and there is only one heap.
Static variables: in the method area.
The static variable is in the method area, and there is only one method area.
The heap and method area are shared by multiple threads, so there may be ** program security issues.
Local Variables + Constants: There will be no thread safety issues.
Member variables: There may be thread safety issues.
Asynchronous programming model:
Thread t1 and thread t2, each executes their own, t1 does not care about t2, t2 does not care about t1, no one needs to wait for anyone, this programming model is called: asynchronous programming model.
Actually, it's just that: multi-threaded concurrency (more efficient. )
Synchronous Programming Model:
Thread t1 and thread t2, when the ** program t1 is executed, you must wait for the t2 thread to execute.
The end, or when the T2 thread is executed, it is necessary to wait for the T1 thread to finish, and the waiting relationship between the two threads occurs, which is the synchronous programming model.
Less efficient. Threads are queued for execution.