Mercurial > hg > Database > Christie
view src/main/java/christie/codegear/StartCodeGear.java @ 8:efaa7ad906b3
Implement Queue in DataGearManager
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 28 Dec 2017 18:33:22 +0900 |
parents | 21372a589bd3 |
children | bcd4f2c19185 |
line wrap: on
line source
package christie.codegear; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public abstract class StartCodeGear extends CodeGear{ ConcurrentHashMap<String, CodeGearManager> cgms = new ConcurrentHashMap<>(); LinkedBlockingQueue<Runnable> taskQueue = new LinkedBlockingQueue<Runnable>(); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads Runtime.getRuntime().availableProcessors(), Integer.MAX_VALUE, // keepAliveTime TimeUnit.SECONDS, taskQueue); public CodeGearManager createCGM(String name){ CodeGearManager cgm = new CodeGearManager(threadPoolExecutor, cgms); cgms.put(name, cgm); return cgm; } public CodeGearManager getCGM(String name){ return cgms.get(name); } }