java virtual machine thread-safe implementations (synchronous blocking and non-blocking synchronous)

java virtual machine thread-safe implementations:

A blocking synchronization (sync mutual exclusion)

1.synchronized is such a synchronized manner.

2. The main problem is that the process of blocking and wake caused by performance issues.

3. It is a pessimistic concurrency strategy, regardless of whether there really competition to share data, should be locked.

Two non-blocking synchronization

1. It is based on optimistic concurrency strategy collision detection. First carry out the first operation, if there is no contention on the successful, if there is contention, the conflict, and then take other compensation measures.

 

Published 415 original articles · won praise 434 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_41901915/article/details/103654536