1. Lightweight locks (Lock) heavyweight lock (synchronized): locks are reentrant
2. reentrant lock (lock recursion): Method nested method, the lock can be passed
3. The read-write lock (ReentrantReadWriteLock) - separate read and write
Read lock (get the value of information) and write locks (the value of the operation)
4. optimistic locking
Nature did not lock, more efficient, non-blocking, no wait, and try again.
5. pessimistic locking
Belongs to the heavyweights lock will block, we will be waiting. synchronized belong pessimistic locking.
6. The underlying principle is that the atomic class CAS no lock technology (Comparative then exchanged)
7.CAS no lock mechanism
V: represents a variable to be updated; main memory
E: represents the expected value; local memory
N: represents the new value
If V = E (main memory value coincides with the value of local memory), Description: not modified, the value V is N
If V! = E (main memory and the local memory values do not match value), has been modified, main memory refresh cycle comparison