class CachedData {
   Object data;
   volatile boolean cacheValid;
   final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();

   void processCachedData() {
     rwl.readLock().lock();
     if (!cacheValid) {
       // Must release read lock before acquiring write lock
       rwl.readLock().unlock();
       rwl.writeLock().lock();
       try {
         // Recheck state because another thread might have
         // acquired write lock and changed state before we did.
         if (!cacheValid) {
           data = ...
           cacheValid = true;
         }
         // Downgrade by acquiring read lock before releasing write lock
         rwl.readLock().lock();
       } finally {
         rwl.writeLock().unlock(); // Unlock write, still hold read
       }
     }

     try {
       use(data);
     } finally {
       rwl.readLock().unlock();
     }
   }
 }

@@ -1,8 +1,46 @@
+//%E5%8F%82%E8%A7%81 ReentrantReadWriteLock %E7%9A%84javadoc%0A%0A
 class Ca
@@ -306,24 +306,57 @@
  write lock%0A
+        //%E8%AF%BB%E9%94%81-%3E%E5%86%99%E9%94%81%EF%BC%9A %E8%8E%B7%E5%8F%96%E5%86%99%E9%94%81%E4%B9%8B%E5%89%8D%EF%BC%8C%E5%BF%85%E9%A1%BB%E5%85%88%E9%87%8A%E6%94%BE%E8%AF%BB%E9%94%81%0A
        rwl.r
@@ -631,24 +631,24 @@
 %0A         %7D%0A
-
          // 
@@ -700,32 +700,86 @@
 sing write lock%0A
+         //%E5%86%99%E9%94%81-%3E%E8%AF%BB%E9%94%81%EF%BC%9A %E5%86%99%E9%94%81%E5%8F%AF%E4%BB%A5%E9%99%8D%E7%BA%A7%E4%B8%BA%E8%AF%BB%E9%94%81%EF%BC%8C%E6%89%80%E4%BB%A5%E5%85%88%E8%8E%B7%E5%8F%96%E8%AF%BB%E9%94%81%E8%BF%99%E4%B8%AA%E6%93%8D%E4%BD%9C%E5%8F%AF%E4%BB%A5%E6%88%90%E5%8A%9F%EF%BC%8C%E7%84%B6%E5%90%8E%E5%86%8D%E9%87%8A%E6%94%BE%E5%86%99%E9%94%81 %0A
          rwl.rea

Update sample.java