if (timeoutThreadPool == null)
{
int maxNumberThreads = MAX_NUM_TIMEOUT_THREADS_DEFAULT;
int maxTimeoutQueueSize = -1;
BasicThreadPool pool = new BasicThreadPool("HTTP timeout");
log.debug("created new thread pool: " + pool);
Object param = configuration.get(MAX_NUM_TIMEOUT_THREADS);
if (param instanceof String)
{
try
{
maxNumberThreads = Integer.parseInt((String) param);
}
catch (NumberFormatException e)
{
log.error("maxNumberThreads parameter has invalid format: " + param);
}
}
else if (param != null)
{
log.error("maxNumberThreads parameter must be a string in integer format: " + param);
}
param = configuration.get(MAX_TIMEOUT_QUEUE_SIZE);
if (param instanceof String)
{
try
{
maxTimeoutQueueSize = Integer.parseInt((String) param);
}
catch (NumberFormatException e)
{
log.error("maxTimeoutQueueSize parameter has invalid format: " + param);
}
}
else if (param != null)
{
log.error("maxTimeoutQueueSize parameter must be a string in integer format: " + param);
}
pool.setMaximumPoolSize(maxNumberThreads);
if (maxTimeoutQueueSize > 0)
{
pool.setMaximumQueueSize(maxTimeoutQueueSize);
}
pool.setBlockingMode(BlockingMode.RUN);
timeoutThreadPool = pool;
}
}
return timeoutThreadPool;
}