Explicit Locks
Explicit Lock
Before Java 5.0, the only mechanisms for coordinating access to shared data were synchronized and volatile. Java 5.0 adds another option: ReentrantLock.Contrary to what some have written, ReentrantLock is not a replacement for intrinsic locking, but rather an alternative with advanced features for when intrinsic locking proves too limited.
在Jav 5.0之前的版本中,协调共享数据的访问只能通过synchronized和volatile。在Java 5.0中,我们多了另一个选择:ReentrantLock.有些人认为ReentrantLock是为了取代内置的锁机制,但事实并非如此--ReentrantLock提供了在内置锁机制限制过多的情况下的一种替代方案。
13.1 Lock And ReentrantLock
13.1 Lock与ReentrantLock