天天看点

java maximumpoolsize_Java ThreadPoolExecutor.getMaximumPoolSize方法代码示例

import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类

protected void fireServerAttributeUpdateEvent(JsfUrl source, Map attrs) {

LOGGER.info("Get server attribute update callback event, source: {}, data: {}", source, attrs);

if (CommonUtils.isNotEmpty(attrs)) { // 需要区分alias

try {

int port = Integer.parseInt(attrs.get("port"));

ThreadPoolExecutor executor = BusinessPool.getBusinessPool(port);

if (executor != null) {

if (attrs.containsKey("core")) {

int coreNew = Integer.parseInt(attrs.get("core"));

if (coreNew != executor.getCorePoolSize()) {

LOGGER.info("Core pool size of business pool at port {} change from {} to {}",

new Object[]{port, executor.getCorePoolSize(), coreNew});

executor.setCorePoolSize(coreNew);

}

}

if (attrs.containsKey("max")) {

int maxNew = Integer.parseInt(attrs.get("max"));

if (maxNew != executor.getMaximumPoolSize()) {

LOGGER.info("Maximum pool size of business pool at port {} change from {} to {}",

new Object[]{port, executor.getMaximumPoolSize(), maxNew});

executor.setMaximumPoolSize(maxNew);

}

}

}

} catch (Exception e) {

LOGGER.warn("Fire server attribute update event error!", e);

}

}

}