Ignore:
Timestamp:
2014-08-16T20:14:24+02:00 (10 years ago)
Author:
Don-vip
Message:

see #9680, see #4626 - multithreaded multipolygon creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7356 r7423  
    4242import java.util.Iterator;
    4343import java.util.List;
     44import java.util.concurrent.ExecutorService;
     45import java.util.concurrent.Executors;
    4446import java.util.regex.Matcher;
    4547import java.util.regex.Pattern;
     
    10641066        return true;
    10651067    }
     1068
     1069    /**
     1070     * Returns a pair containing the number of threads (n), and a thread pool (if n > 1) to perform
     1071     * multi-thread computation in the context of the given preference key.
     1072     * @param pref The preference key
     1073     * @return a pair containing the number of threads (n), and a thread pool (if n > 1, null otherwise)
     1074     * @since 7423
     1075     */
     1076    public static Pair<Integer, ExecutorService> newThreadPool(String pref) {
     1077        int noThreads = Main.pref.getInteger(pref, Runtime.getRuntime().availableProcessors());
     1078        ExecutorService pool = noThreads <= 1 ? null : Executors.newFixedThreadPool(noThreads);
     1079        return new Pair<>(noThreads, pool);
     1080    }
    10661081}
Note: See TracChangeset for help on using the changeset viewer.