In situations where reads greatly outnumber writes, volatile variables may also provide a performance advantage over locking.
在某些情况下,如果读操作远远大于写操作,volatile变量还可以提供优于锁的性能优势。
Unlike locking, volatile operations will never block, so volatiles offer some scalability advantages over locking in the cases where they can be used safely.
volatile操作不会像锁一样造成阻塞,因此,在能够安全使用volatile的情况下,volatile可以提供一些优于锁的可伸缩特性。
So if the goal of double-checked locking is supposed to offer improved performance over a more straightforward synchronized approach, this "fixed" version doesn't help very much either.
所以如果双重检查锁定的目标是提供比更直观的同步方式更好的性能,那么这个“修复的”版本也没有多大帮助。
应用推荐