将锁偏向于一个线程,意味着该线程不需要释放锁的契约。
Biasing a lock to a thread means that the thread is not required to release the lease on the lock.
上图中第一个灰色段显示的是这些线程的对齐,它们可以使用偏向锁(注意所有地址都以00结尾)。
The first section in grey is reporting on the alignment of these thread object so that it may work with biased locking (note all addresses end with 00).
从最初的基准测试结果来看,偏向锁提供了最佳的性能,比其他的优化方式更有效。
The initial benchmarking results demonstrated that biased locking provided the best performance gain compared to any of the other available optimizations.
如果锁刚好只被一个线程访问,则可以使用偏向锁。
If the lock happens to be accessed by only one thread, biased locking can be applied.
红色的行是偏向锁被激活的地方。
The line annotated in red is where biased locking is enabled.
事实上,除了C列以外,每次运行时如果开启偏向锁最终都会提供大致相同的性能提升。
In fact, with the exception of column c, every run with biased locking turned on ended up providing approximately the same boost in performance.
是否执行偏向锁(biased locking,- XX: +UseBiasedLocking);注意,JD k 1.6及更高版本会自动执行这个特性。
Whether or not biased locking is being performed (-xx: + UseBiasedLocking); note that JDK 1.6 + automatically does this.
是否执行偏向锁(biased locking,- XX: +UseBiasedLocking);注意,JD k 1.6及更高版本会自动执行这个特性。
Whether or not biased locking is being performed (-xx: + UseBiasedLocking); note that JDK 1.6 + automatically does this.
应用推荐