Even with a few failed CAS operations, this approach is still likely to be faster than being rescheduled because of lock contention.
即使有少量失败的CAS操作,这种方法仍然会比由于锁争用造成的重新调度快得多。
Even if there are other statements between the synchronized blocks or method calls, the compiler can still perform lock coarsening.
即使在synchronized块或方法调用之间有其他语句,编译器仍然能够执行锁粗化。
And depending on what other optimizations are enabled by the larger basic block, the duration for which the lock is held may not even be lengthened under coarsening.
而且根据更大的基本块支持其他何种优化,在粗化的情况下,持有锁的时间甚至可能不会延长。
应用推荐