Changeset 31546 in osm


Ignore:
Timestamp:
2015-09-11T21:54:18+02:00 (9 years ago)
Author:
wiktorn
Message:

Move tile loading to separate thread to prevent blocking EDT thread with IO actions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r31540 r31546  
    1010import java.util.Map;
    1111import java.util.Map.Entry;
     12import java.util.concurrent.Executor;
     13import java.util.concurrent.Executors;
    1214
    1315import org.openstreetmap.gui.jmapviewer.interfaces.TileJob;
    1416import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    1517import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener;
     18import org.openstreetmap.josm.tools.Utils;
    1619
    1720/**
     
    2124 */
    2225public class OsmTileLoader implements TileLoader {
     26    private final static Executor jobDispatcher =
     27            Executors.newSingleThreadExecutor(
     28                    Utils.newThreadFactory("OsmTileLoader-%d", Thread.NORM_PRIORITY)
     29                    );
    2330
    2431    private final class OsmTileJob implements TileJob {
     
    8996        public void submit(boolean force) {
    9097            this.force = force;
    91             run();
     98            jobDispatcher.execute(this);
    9299        }
    93100    }
Note: See TracChangeset for help on using the changeset viewer.