Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java	(revision 29757)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java	(revision 29822)
@@ -3,5 +3,6 @@
 //License: GPL. Copyright 2008 by Jan Peter Stotz
 
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
@@ -25,28 +26,29 @@
     protected int cacheSize = 200;
 
-    protected Hashtable<String, CacheEntry> hashtable;
+    protected final Map<String, CacheEntry> hash;
 
     /**
      * List of all tiles in their last recently used order
      */
-    protected CacheLinkedListElement lruTiles;
+    protected final CacheLinkedListElement lruTiles;
 
     public MemoryTileCache() {
-        hashtable = new Hashtable<String, CacheEntry>(cacheSize);
+        hash = new HashMap<String, CacheEntry>(cacheSize);
         lruTiles = new CacheLinkedListElement();
     }
 
     @Override
-    public void addTile(Tile tile) {
+    public synchronized void addTile(Tile tile) {
         CacheEntry entry = createCacheEntry(tile);
-        hashtable.put(tile.getKey(), entry);
-        lruTiles.addFirst(entry);
-        if (hashtable.size() > cacheSize)
-            removeOldEntries();
+            hash.put(tile.getKey(), entry);
+            lruTiles.addFirst(entry);
+            if (hash.size() > cacheSize) {
+                removeOldEntries();
+            }
     }
 
     @Override
-    public Tile getTile(TileSource source, int x, int y, int z) {
-        CacheEntry entry = hashtable.get(Tile.getTileKey(source, x, y, z));
+    public synchronized Tile getTile(TileSource source, int x, int y, int z) {
+        CacheEntry entry = hash.get(Tile.getTileKey(source, x, y, z));
         if (entry == null)
             return null;
@@ -61,18 +63,16 @@
      * Removes the least recently used tiles
      */
-    protected void removeOldEntries() {
-        synchronized (lruTiles) {
-            try {
-                while (lruTiles.getElementCount() > cacheSize) {
-                    removeEntry(lruTiles.getLastElement());
-                }
-            } catch (Exception e) {
-                log.warning(e.getMessage());
-            }
-        }
-    }
-
-    protected void removeEntry(CacheEntry entry) {
-        hashtable.remove(entry.tile.getKey());
+    protected synchronized void removeOldEntries() {
+        try {
+            while (lruTiles.getElementCount() > cacheSize) {
+                removeEntry(lruTiles.getLastElement());
+            }
+        } catch (Exception e) {
+            log.warning(e.getMessage());
+        }
+    }
+
+    protected synchronized void removeEntry(CacheEntry entry) {
+        hash.remove(entry.tile.getKey());
         lruTiles.removeEntry(entry);
     }
@@ -85,14 +85,12 @@
      * Clears the cache deleting all tiles from memory
      */
-    public void clear() {
-        synchronized (lruTiles) {
-            hashtable.clear();
-            lruTiles.clear();
-        }
+    public synchronized void clear() {
+        hash.clear();
+        lruTiles.clear();
     }
 
     @Override
     public int getTileCount() {
-        return hashtable.size();
+        return hash.size();
     }
 
@@ -107,7 +105,7 @@
      *            new maximum number of tiles
      */
-    public void setCacheSize(int cacheSize) {
+    public synchronized void setCacheSize(int cacheSize) {
         this.cacheSize = cacheSize;
-        if (hashtable.size() > cacheSize)
+        if (hash.size() > cacheSize)
             removeOldEntries();
     }
@@ -157,5 +155,5 @@
         }
 
-        public synchronized void clear() {
+        public void clear() {
             elementCount = 0;
             firstElement = null;
@@ -168,5 +166,5 @@
          * @param element new element to be added
          */
-        public synchronized void addFirst(CacheEntry element) {
+        public void addFirst(CacheEntry element) {
             if (element == null) return;
             if (elementCount == 0) {
@@ -189,5 +187,5 @@
          * @param element element to be removed
          */
-        public synchronized void removeEntry(CacheEntry element) {
+        public void removeEntry(CacheEntry element) {
             if (element == null) return;
             if (element.next != null) {
@@ -206,5 +204,5 @@
         }
 
-        public synchronized void moveElementToFirstPos(CacheEntry entry) {
+        public void moveElementToFirstPos(CacheEntry entry) {
             if (firstElement == entry)
                 return;
