Learning immediately: https://edu.csdn.net/course/play/9827/208797?utm_source=blogtoedu
How to avoid thread-safety issues
Causes of thread safety issues
1. multithreaded environment
2. Multiple threads operating the same shared resources
3. the shared resource non-atomic operations
How to avoid?
Causes can break at any point in three
1. The single-threaded multi-threaded changed (the necessary code lock access)
2. do not share resources (the ThreadLocal, not shared, the operation of the stateless, immutable)
3. the shared resource atomicity operations. (Lock, built using JDK classes atomic operation, concurrent corresponding tools provided JUC)