What is meant by “fast-path” uncontended synchronization?

前端 未结 3 891
清歌不尽
清歌不尽 2021-02-14 05:18

From the Performance and Scalability chapter of the JCIP book:

The synchronized mechanism is optimized for the uncontended case(volatile is alw

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 06:01

    The first step of acquiring a synchronized lock is a single volatile write (monitor owner field). If the lock is uncontested then that is all which will happen.

    If the lock is contested then there will be various context switches and other mechanisms which will increase clock cycles.

提交回复
热议问题