Ignore:
Timestamp:
2017-01-07T09:44:59+01:00 (7 years ago)
Author:
wiktorn
Message:

Fix thread pool for WMS

Because threds in WMS download ThreadPool never died, the unreferenced ThreadPool object (and its threads) was never cleared. To fix this minimum size of ThreadPool was changed to 0.

But due to the fact, that ThreadPoolExecutor spawns new Thread only when workQueue refuses to take a new job, workaround is implemented in HostLimitQueue based on: http://stackoverflow.com/questions/9622599/java-threadpoolexecutor-strategy-direct-handoff-with-queue#

WMS Settings was fixed so now WMS has it's own THREAD_LIMIT setting not connected to JCS default setting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java

    r10877 r11438  
    7878     */
    7979    public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers) {
    80         return new ThreadPoolExecutor(
    81                 workers, // keep the thread number constant
     80        HostLimitQueue workQueue = new HostLimitQueue(HOST_LIMIT.get().intValue());
     81        ThreadPoolExecutor executor = new ThreadPoolExecutor(
     82                0, // 0 so for unused thread pools threads will eventually die, freeing also the threadpool
    8283                workers, // do not this number of threads
    83                 30, // keepalive for thread
     84                300, // keepalive for thread
    8485                TimeUnit.SECONDS,
    85                 new HostLimitQueue(HOST_LIMIT.get().intValue()),
     86                workQueue,
    8687                Utils.newThreadFactory(nameFormat, Thread.NORM_PRIORITY)
    8788                );
     89        workQueue.setExecutor(executor);
     90        return executor;
    8891    }
    8992
Note: See TracChangeset for help on using the changeset viewer.