--- dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java 2015/02/09 11:37:56 2258 +++ dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java 2015/02/09 13:21:39 2259 @@ -6,6 +6,7 @@ import java.util.logging.FileHandler; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; +import java.util.concurrent.*; public class LookupMain { @@ -29,6 +30,17 @@ static Statistik stoersteDataset = new Statistik(); static Adresse[] alleDaekkedeAdresser; + + static ThreadPoolExecutor threadPool; + + private static void setupThreadPool() { + threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(max_workers, new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "lookupWorker"); + } + }); + } public static void main(String[] args) throws Exception { @@ -61,6 +73,7 @@ } logger.info("Starting with MAX_WORKERS:" + max_workers); + setupThreadPool(); verbose = Boolean.parseBoolean( conf.getSafeProperty("VERBOSE") ); @@ -109,7 +122,7 @@ db.resetResultTable(); for(String postnr : postnumre) { - Lookup lookup = new Lookup(postnr, db); + Lookup lookup = new Lookup(postnr, db, threadPool); lookup.doLookup(); } @@ -130,7 +143,7 @@ logger.info( "AlleDaekkedeAdresser.length=" + alleDaekkedeAdresser.length); } - Lookup lookup = new Lookup("458x", db); + Lookup lookup = new Lookup("458x", db, threadPool); lookup.doLookup(); }