Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 7079)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java	(revision 7080)
@@ -25,4 +25,5 @@
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,8 +36,6 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-
 import javax.swing.AbstractButton;
 import javax.swing.FocusManager;
-
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
@@ -83,6 +82,8 @@
     
     static {
-        noThreads = Runtime.getRuntime().availableProcessors();
-        styleCreatorPool = Executors.newFixedThreadPool(noThreads);
+        noThreads = Main.pref.getInteger(
+                "mappaint.StyledMapRenderer.style_creation.numberOfThreads", 
+                Runtime.getRuntime().availableProcessors());
+        styleCreatorPool = noThreads <= 1 ? null : Executors.newFixedThreadPool(noThreads);
     }
 
@@ -234,4 +235,29 @@
 
             return Float.compare(this.style.object_z_index, other.style.object_z_index);
+        }
+    }
+
+    /**
+     * Joined List build from two Lists (read-only).
+     * 
+     * Extremely simple single-purpose implementation.
+     * @param <T> 
+     */
+    public static class CompositeList<T> extends AbstractList<T> {
+        List<T> a,b;
+
+        public CompositeList(List<T> a, List<T> b) {
+            this.a = a;
+            this.b = b;
+        }
+
+        @Override
+        public T get(int index) {
+            return index < a.size() ? a.get(index) : b.get(index - a.size());
+        }
+
+        @Override
+        public int size() {
+            return a.size() + b.size();
         }
     }
@@ -1315,5 +1341,5 @@
         styles = MapPaintStyles.getStyles();
         styles.setDrawMultipolygon(drawMultipolygon);
-
+        
         highlightWaySegments = data.getHighlightedWaySegments();
         
@@ -1326,8 +1352,8 @@
 
         class ComputeStyleListWorker implements Callable<List<StyleRecord>>, Visitor {
-            private final List<StyleRecord> styleList;
             private final List<? extends OsmPrimitive> input;
             private final int from;
             private final int to;
+            private final List<StyleRecord> output;
 
             /**
@@ -1337,9 +1363,9 @@
              * @param to last index + 1
              */
-            public ComputeStyleListWorker(List<? extends OsmPrimitive> input, int from, int to) {
-                this.styleList = new ArrayList<>(to - from);
+            public ComputeStyleListWorker(final List<? extends OsmPrimitive> input, int from, int to, List<StyleRecord> output) {
                 this.input = input;
                 this.from = from;
                 this.to = to;
+                this.output = output;
             }
             
@@ -1352,5 +1378,5 @@
                     }
                 }
-                return styleList;
+                return output;
             }
             
@@ -1400,5 +1426,5 @@
                 StyleList sl = styles.get(osm, circum, nc);
                 for (ElemStyle s : sl) {
-                    styleList.add(new StyleRecord(s, osm, flags));
+                    output.add(new StyleRecord(s, osm, flags));
                 }
             }
@@ -1408,7 +1434,7 @@
                 for (ElemStyle s : sl) {
                     if (drawMultipolygon && drawArea && s instanceof AreaElemStyle && (flags & FLAG_DISABLED) == 0) {
-                        styleList.add(new StyleRecord(s, osm, flags));
+                        output.add(new StyleRecord(s, osm, flags));
                     } else if (drawRestriction && s instanceof NodeElemStyle) {
-                        styleList.add(new StyleRecord(s, osm, flags));
+                        output.add(new StyleRecord(s, osm, flags));
                     }
                 }
@@ -1421,24 +1447,32 @@
                         continue;
                     }
-                    styleList.add(new StyleRecord(s, osm, flags));
-                }
-            }
-        }
-
-        final List<ComputeStyleListWorker> tasks = new ArrayList<>();
-        final List<StyleRecord> allStyleElems = new ArrayList<>();
+                    output.add(new StyleRecord(s, osm, flags));
+                }
+            }
+        }
+        List<Node> nodes = data.searchNodes(bbox);
+        List<Way> ways = data.searchWays(bbox);
+        List<Relation> relations = data.searchRelations(bbox);
+        
+        final List<StyleRecord> allStyleElems = new ArrayList<>(nodes.size()+ways.size()+relations.size());
         
         class ConcurrentTasksHelper {
-            void createTasks(List<? extends OsmPrimitive> prims) {
-                int bucketsize = Math.max(100, prims.size()/noThreads/3);
-                for (int i=0; i*bucketsize < prims.size(); i++) {
-                    tasks.add(new ComputeStyleListWorker(prims, i*bucketsize, Math.min((i+1)*bucketsize, prims.size())));
-                }
-            }
             
-            void runIt() {
-                if (tasks.size() == 1) {
+            void process(List<? extends OsmPrimitive> prims) {
+                final List<ComputeStyleListWorker> tasks = new ArrayList<>();
+                final int bucketsize = Math.max(100, prims.size()/noThreads/3);
+                final int noBuckets = (prims.size() + bucketsize - 1) / bucketsize;
+                final boolean singleThread = noThreads == 1 || noBuckets == 1;
+                for (int i=0; i<noBuckets; i++) {
+                    int from = i*bucketsize;
+                    int to = Math.min((i+1)*bucketsize, prims.size());
+                    List<StyleRecord> target = singleThread ? allStyleElems : new ArrayList<StyleRecord>(to - from);
+                    tasks.add(new ComputeStyleListWorker(prims, from, to, target));
+                }
+                if (singleThread) {
                     try {
-                        allStyleElems.addAll(tasks.get(0).call());
+                        for (ComputeStyleListWorker task : tasks) {
+                            task.call();
+                        }
                     } catch (Exception ex) {
                         throw new RuntimeException(ex);
@@ -1462,12 +1496,8 @@
         // (Could be synchronized, but try to avoid this for
         // performance reasons.)
-        helper.createTasks(data.searchRelations(bbox));
-        helper.runIt();
-        
-        tasks.clear();
-        helper.createTasks(data.searchNodes(bbox));
-        helper.createTasks(data.searchWays(bbox));
-        helper.runIt();
-        
+        helper.process(relations);
+        @SuppressWarnings("unchecked")
+        List<OsmPrimitive> nodesAndWays = (List) new CompositeList(nodes, ways);
+        helper.process(nodesAndWays);
         
         if (Main.isTraceEnabled()) {
