title: Concurrency and CacheLoader.load()
body: <p>Should I synchronize the code in CacheLoader.load()? </p>
  
  <p>I have code like this:</p>
  
  <pre><code>final Calculator calculator = new Calculator();
  
  final LoadingCache&lt;Key, Value&gt; cache = CacheBuilder.newBuilder().build(new CacheLoader&lt;Key, Value&gt;(){
          @Override
          public Value load(final Key key) throws Exception {
              return calculator.calc(key);
          }} );
  </code></pre>
  
  <p>If the cache needs to load the values of two different keys from two different threads do I have to worry about thread interference in my Calculator object? I.e. should I declare my Calculator.calc() method synchronized (or do something else to ensure thread-safety)?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Just so that it is clear I am asking specifically with regards to caching in Guava: <a href="http://code.google.com/p/guava-libraries/wiki/CachesExplained" rel="nofollow">http://code.google.com/p/guava-libraries/wiki/CachesExplained</a></p>