Study Notes (20): 19 years and principles of concurrent programming video training tutorials entry to the master - how to avoid thread-safety issues ...

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)

 

Published 22 original articles · won praise 21 · views 255

Guess you like

Origin blog.csdn.net/weixin_45831970/article/details/104377882