diff --git src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java
index 07928c6..efa50d4 100644
--- src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java
+++ src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java
@@ -5,5 +5,5 @@ package org.openstreetmap.gui.jmapviewer.interfaces;
  * Interface that allow cleaning the tile cache without specifying exact type of loader
  */
 public interface CachedTileLoader {
-    public void clearCache();
+    public void clearCache(TileSource source);
 }
diff --git src/org/openstreetmap/josm/data/cache/JCSCacheManager.java src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
index bddfb28..8f3f70d 100644
--- src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
+++ src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
@@ -2,7 +2,9 @@
 package org.openstreetmap.josm.data.cache;
 
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.nio.channels.FileLock;
 import java.text.MessageFormat;
 import java.util.Properties;
 import java.util.logging.Handler;
@@ -39,18 +41,28 @@ public class JCSCacheManager {
     private static long maxObjectTTL        = Long.MAX_VALUE;
     private final static String PREFERENCE_PREFIX = "jcs.cache";
     private final static IndexedDiskCacheFactory diskCacheFactory = new IndexedDiskCacheFactory();
+    private static FileLock cacheDirLock = null;
 
     /**
      * default objects to be held in memory by JCS caches (per region)
      */
     public static final IntegerProperty DEFAULT_MAX_OBJECTS_IN_MEMORY  = new IntegerProperty(PREFERENCE_PREFIX + ".max_objects_in_memory", 1000);
 
+    @SuppressWarnings("resource")
     private static void initialize() throws IOException {
         File cacheDir = new File(Main.pref.getCacheDirectory(), "jcs");
 
         if ((!cacheDir.exists() && !cacheDir.mkdirs()))
             throw new IOException("Cannot access cache directory");
 
+        File cacheDirLockPath = new File(cacheDir, ".lock");
+        if (!cacheDirLockPath.exists())
+            cacheDirLockPath.createNewFile();
+        cacheDirLock = new FileOutputStream(cacheDirLockPath).getChannel().tryLock();
+
+        if (cacheDirLock == null)
+            log.log(Level.WARNING, "Cannot lock cache directory. Will not use disk cache");
+
         // raising logging level gives ~500x performance gain
         // http://westsworld.dk/blog/2008/01/jcs-and-performance/
         Logger jcsLog = Logger.getLogger("org.apache.commons.jcs");
@@ -138,7 +150,7 @@ public class JCSCacheManager {
     private static <K,V> CacheAccess<K, V> getCacheInner(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) {
         CompositeCache<K, V> cc = cacheManager.getCache(cacheName, getCacheAttributes(maxMemoryObjects));
 
-        if (cachePath != null) {
+        if (cachePath != null && cacheDirLock != null) {
             IndexedDiskCacheAttributes diskAttributes = getDiskCacheAttributes(maxDiskObjects, cachePath);
             diskAttributes.setCacheName(cacheName);
             IndexedDiskCache<K, V> diskCache = diskCacheFactory.createCache(diskAttributes, cacheManager, null, new StandardSerializer());
diff --git src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
index d2709aa..6b612e9 100644
--- src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
+++ src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
@@ -61,7 +61,7 @@ public class TMSCachedTileLoader implements TileLoader, CachedTileLoader, TileCa
     }
 
     @Override
-    public void clearCache() {
+    public void clearCache(TileSource source) {
         this.cache.clear();
     }
 
diff --git src/org/openstreetmap/josm/gui/layer/TMSLayer.java src/org/openstreetmap/josm/gui/layer/TMSLayer.java
index 1b5e05b..a496320 100644
--- src/org/openstreetmap/josm/gui/layer/TMSLayer.java
+++ src/org/openstreetmap/josm/gui/layer/TMSLayer.java
@@ -193,7 +193,7 @@ public class TMSLayer extends ImageryLayer implements ImageObserver, TileLoaderL
     void clearTileCache(ProgressMonitor monitor) {
         tileCache.clear();
         if (tileLoader instanceof CachedTileLoader) {
-            ((CachedTileLoader)tileLoader).clearCache();
+            ((CachedTileLoader)tileLoader).clearCache(tileSource);
         }
     }
 
