synchronized lock upgrade process

No lock - biased locking - Lightweight lock (spinlocks CAS) - heavyweight lock

1. biased locking

  Specific to a thread, a biased locking thread, such as thread id

2. Lightweight lock

  When there are multiple threads competing for a lock, the lock upgrade lightweight, the stack pointer to the record, a process known as CAS

3. heavyweight lock

  When competing threads more than 10 times, upgraded to heavyweight lock, user mode to kernel mode to upgrade the efficiency of slow

Guess you like

Origin www.cnblogs.com/zhaoatian/p/12345103.html