+ public LockHolder lockForWriting() {
+ ReentrantReadWriteLock.WriteLock wLock = lock.writeLock();
+ wLock.lock();
+
+ ReentrantReadWriteLock.ReadLock rLock = lock.readLock();
+ rLock.lock();
+
+ return new LockHolder(rLock, wLock);
+ }
+ public LockHolder lockForReading() {
+ ReentrantReadWriteLock.ReadLock rLock = lock.readLock();
+ rLock.lock();
+ return new LockHolder(rLock);
+ }