Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java	(revision 30768)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java	(revision 30769)
@@ -10,4 +10,5 @@
 import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -85,4 +86,5 @@
         VERTICAL
     }
+
     protected ZOOM_BUTTON_STYLE zoomButtonStyle;
 
@@ -109,7 +111,7 @@
         tileSource = new OsmTileSource.Mapnik();
         tileController = new TileController(tileSource, tileCache, this);
-        mapMarkerList = new LinkedList<>();
-        mapPolygonList = new LinkedList<>();
-        mapRectangleList = new LinkedList<>();
+        mapMarkerList = Collections.synchronizedList(new LinkedList<MapMarker>());
+        mapPolygonList = Collections.synchronizedList(new LinkedList<MapPolygon>());
+        mapRectangleList = Collections.synchronizedList(new LinkedList<MapRectangle>());
         mapMarkersVisible = true;
         mapRectanglesVisible = true;
@@ -264,37 +266,43 @@
 
         if (markers) {
-            for (MapMarker marker : mapMarkerList) {
-                if(marker.isVisible()){
-                    int x = tileSource.LonToX(marker.getLon(), mapZoomMax);
-                    int y = tileSource.LatToY(marker.getLat(), mapZoomMax);
-                    x_max = Math.max(x_max, x);
-                    y_max = Math.max(y_max, y);
-                    x_min = Math.min(x_min, x);
-                    y_min = Math.min(y_min, y);
-                }
-            }
-        }
-
-        if (rectangles) {
-            for (MapRectangle rectangle : mapRectangleList) {
-                if(rectangle.isVisible()){
-                    x_max = Math.max(x_max, tileSource.LonToX(rectangle.getBottomRight().getLon(), mapZoomMax));
-                    y_max = Math.max(y_max, tileSource.LatToY(rectangle.getTopLeft().getLat(), mapZoomMax));
-                    x_min = Math.min(x_min, tileSource.LonToX(rectangle.getTopLeft().getLon(), mapZoomMax));
-                    y_min = Math.min(y_min, tileSource.LatToY(rectangle.getBottomRight().getLat(), mapZoomMax));
-                }
-            }
-        }
-
-        if (polygons) {
-            for (MapPolygon polygon : mapPolygonList) {
-                if(polygon.isVisible()){
-                    for (ICoordinate c : polygon.getPoints()) {
-                        int x = tileSource.LonToX(c.getLon(), mapZoomMax);
-                        int y = tileSource.LatToY(c.getLat(), mapZoomMax);
+            synchronized (mapMarkerList) {
+                for (MapMarker marker : mapMarkerList) {
+                    if (marker.isVisible()) {
+                        int x = tileSource.LonToX(marker.getLon(), mapZoomMax);
+                        int y = tileSource.LatToY(marker.getLat(), mapZoomMax);
                         x_max = Math.max(x_max, x);
                         y_max = Math.max(y_max, y);
                         x_min = Math.min(x_min, x);
                         y_min = Math.min(y_min, y);
+                    }
+                }
+            }
+        }
+
+        if (rectangles) {
+            synchronized (mapRectangleList) {
+                for (MapRectangle rectangle : mapRectangleList) {
+                    if (rectangle.isVisible()) {
+                        x_max = Math.max(x_max, tileSource.LonToX(rectangle.getBottomRight().getLon(), mapZoomMax));
+                        y_max = Math.max(y_max, tileSource.LatToY(rectangle.getTopLeft().getLat(), mapZoomMax));
+                        x_min = Math.min(x_min, tileSource.LonToX(rectangle.getTopLeft().getLon(), mapZoomMax));
+                        y_min = Math.min(y_min, tileSource.LatToY(rectangle.getBottomRight().getLat(), mapZoomMax));
+                    }
+                }
+            }
+        }
+
+        if (polygons) {
+            synchronized (mapPolygonList) {
+                for (MapPolygon polygon : mapPolygonList) {
+                    if (polygon.isVisible()) {
+                        for (ICoordinate c : polygon.getPoints()) {
+                            int x = tileSource.LonToX(c.getLon(), mapZoomMax);
+                            int y = tileSource.LatToY(c.getLat(), mapZoomMax);
+                            x_max = Math.max(x_max, x);
+                            y_max = Math.max(y_max, y);
+                            x_min = Math.min(x_min, x);
+                            y_min = Math.min(y_min, y);
+                        }
                     }
                 }
@@ -320,5 +328,4 @@
     }
 
-
     /**
      * Sets the displayed map pane and zoom level so that all map markers are
@@ -430,5 +437,5 @@
      */
     public Integer getLatOffset(double lat, double offset, boolean checkOutside) {
-        int y = tileSource.LatToY(lat+offset, zoom);
+        int y = tileSource.LatToY(lat + offset, zoom);
         y -= center.y - getHeight() / 2;
         if (checkOutside) {
@@ -457,11 +464,12 @@
      */
     public Integer getRadius(MapMarker marker, Point p) {
-        if(marker.getMarkerStyle() == MapMarker.STYLE.FIXED)
-            return (int)marker.getRadius();
-        else if(p!=null){
+        if (marker.getMarkerStyle() == MapMarker.STYLE.FIXED)
+            return (int) marker.getRadius();
+        else if (p != null) {
             Integer radius = getLatOffset(marker.getLat(), marker.getRadius(), false);
-            radius = radius==null?null:p.y-radius.intValue();
+            radius = radius == null ? null : p.y - radius.intValue();
             return radius;
-        }else return null;
+        } else
+            return null;
     }
 
@@ -500,16 +508,16 @@
      */
     public double getMeterPerPixel() {
-        Point origin=new Point(5,5);
-        Point center=new Point(getWidth()/2, getHeight()/2);
-
-        double pDistance=center.distance(origin);
-
-        Coordinate originCoord=getPosition(origin);
-        Coordinate centerCoord=getPosition(center);
+        Point origin = new Point(5, 5);
+        Point center = new Point(getWidth() / 2, getHeight() / 2);
+
+        double pDistance = center.distance(origin);
+
+        Coordinate originCoord = getPosition(origin);
+        Coordinate centerCoord = getPosition(center);
 
         double mDistance = tileSource.getDistance(originCoord.getLat(), originCoord.getLon(),
                 centerCoord.getLat(), centerCoord.getLon());
 
-        return mDistance/pDistance;
+        return mDistance / pDistance;
     }
 
@@ -614,18 +622,27 @@
 
         if (mapPolygonsVisible && mapPolygonList != null) {
-            for (MapPolygon polygon : mapPolygonList) {
-                if(polygon.isVisible()) paintPolygon(g, polygon);
+            synchronized (mapPolygonList) {
+                for (MapPolygon polygon : mapPolygonList) {
+                    if (polygon.isVisible())
+                        paintPolygon(g, polygon);
+                }
             }
         }
 
         if (mapRectanglesVisible && mapRectangleList != null) {
-            for (MapRectangle rectangle : mapRectangleList) {
-                if(rectangle.isVisible()) paintRectangle(g, rectangle);
+            synchronized (mapRectangleList) {
+                for (MapRectangle rectangle : mapRectangleList) {
+                    if (rectangle.isVisible())
+                        paintRectangle(g, rectangle);
+                }
             }
         }
 
         if (mapMarkersVisible && mapMarkerList != null) {
-            for (MapMarker marker : mapMarkerList) {
-                if(marker.isVisible())paintMarker(g, marker);
+            synchronized (mapMarkerList) {
+                for (MapMarker marker : mapMarkerList) {
+                    if (marker.isVisible())
+                        paintMarker(g, marker);
+                }
             }
         }
@@ -638,5 +655,5 @@
      */
     protected void paintMarker(Graphics g, MapMarker marker) {
-        Point p = getMapPosition(marker.getLat(), marker.getLon(), marker.getMarkerStyle()==MapMarker.STYLE.FIXED);
+        Point p = getMapPosition(marker.getLat(), marker.getLon(), marker.getMarkerStyle() == MapMarker.STYLE.FIXED);
         Integer radius = getRadius(marker, p);
         if (scrollWrapEnabled) {
@@ -1026,19 +1043,19 @@
         }
         switch (style) {
-            case HORIZONTAL:
-                zoomSlider.setBounds(10, 10, 30, 150);
-                zoomInButton.setBounds(4, 155, 18, 18);
-                zoomOutButton.setBounds(26, 155, 18, 18);
-                break;
-            case VERTICAL:
-                zoomSlider.setBounds(10, 27, 30, 150);
-                zoomInButton.setBounds(14, 8, 20, 20);
-                zoomOutButton.setBounds(14, 176, 20, 20);
-                break;
-            default:
-                zoomSlider.setBounds(10, 10, 30, 150);
-                zoomInButton.setBounds(4, 155, 18, 18);
-                zoomOutButton.setBounds(26, 155, 18, 18);
-                break;
+        case HORIZONTAL:
+            zoomSlider.setBounds(10, 10, 30, 150);
+            zoomInButton.setBounds(4, 155, 18, 18);
+            zoomOutButton.setBounds(26, 155, 18, 18);
+            break;
+        case VERTICAL:
+            zoomSlider.setBounds(10, 27, 30, 150);
+            zoomInButton.setBounds(14, 8, 20, 20);
+            zoomOutButton.setBounds(14, 176, 20, 20);
+            break;
+        default:
+            zoomSlider.setBounds(10, 10, 30, 150);
+            zoomInButton.setBounds(4, 155, 18, 18);
+            zoomOutButton.setBounds(26, 155, 18, 18);
+            break;
         }
         repaint();
@@ -1088,7 +1105,7 @@
     void fireJMVEvent(JMVCommandEvent evt) {
         Object[] listeners = evtListenerList.getListenerList();
-        for (int i=0; i<listeners.length; i+=2) {
-            if (listeners[i]==JMapViewerEventListener.class) {
-                ((JMapViewerEventListener)listeners[i+1]).processCommand(evt);
+        for (int i = 0; i < listeners.length; i += 2) {
+            if (listeners[i] == JMapViewerEventListener.class) {
+                ((JMapViewerEventListener) listeners[i + 1]).processCommand(evt);
             }
         }
