protected ExecutorService createExecutorService(Properties config) { int corePoolSize = StringUtil.toInt((String) config.remove("corePoolSize"), 5); int maximumPoolSize = StringUtil.toInt((String) config.remove("maxPoolSize"), 50); int keepAliveMilSeconds = StringUtil.toInt((String) config.remove("keepAliveMilSeconds"), 60000); ThreadPoolExecutor e = new ThreadPoolExecutor( corePoolSize, maximumPoolSize, keepAliveMilSeconds, TimeUnit.MILLISECONDS, createBlockingQueue(config), createThreadFactory(config)); return e; }
/** 默认使用ArrayBlockingQueue */ protected BlockingQueue<Runnable> createBlockingQueue(Properties config) { int queueSize = StringUtil.toInt((String) config.remove("queueSize"), 2048); return new ArrayBlockingQueue<Runnable>(queueSize); }