Another optimization that can be used to reduce the cost of locking is lock coarsening.
另一个可以用来降低锁定成本的优化是锁粗化(lock coarsening)。
Lock coarsening is the process of merging adjacent synchronized blocks that use the same lock object.
锁粗化就是把使用同一锁对象的相邻同步块合并的过程。
Lock coarsening occurs when adjacent synchronized blocks may be merged into one synchronized block.
当多个彼此靠近的同步块可以合并到一起,形成一个同步块的时候,就会进行锁粗化。
应用推荐