title: Concurrent LRU cache implementation
body: <p>I need thread safe and efficient <code>LRU</code> cache implementation code.
  below code is not thread safe. Is this code can be enhanced using <code>ConcurrentHashMap</code>.
  Thanks in advance. </p>
  
  <pre><code>private class LruCache&lt;A, B&gt; extends LinkedHashMap&lt;A, B&gt; {
      private final int maxEntries;
  
      public LruCache(final int maxEntries) {
          super(maxEntries + 1, 1.0f, true);
          this.maxEntries = maxEntries;
      }
  
      @Override
      protected boolean removeEldestEntry(final Map.Entry&lt;A, B&gt; eldest) {
          return super.size() &gt; maxEntries;
      }
  }
  </code></pre>