--- dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java 2015/02/09 13:21:39 2259 +++ dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/LookupMain.java 2015/02/09 14:00:53 2260 @@ -34,12 +34,7 @@ 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"); - } - }); + threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(max_workers, new WorkerThreadFactory() ); } @@ -146,6 +141,8 @@ Lookup lookup = new Lookup("458x", db, threadPool); lookup.doLookup(); } + + threadPool.shutdown(); long now = System.currentTimeMillis(); long elapsed = now - start ; @@ -182,5 +179,14 @@ int hours = (int) ((milliseconds / (1000*60*60)) % 24); return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, mseconds); - } + } + + static class WorkerThreadFactory implements ThreadFactory { + int count = 0; + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "lookupWorker/" + count++); + } + } }