mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "이희승 (Trustin Lee) <trus...@gmail.com>
Subject Re: sharing Executor between IoServices
Date Wed, 02 Apr 2008 03:41:14 GMT
Hi Cem,

Cem Uzunlar wrote:
>>> 2) NioSocketAcceptor acceptor = new NioSocketAcceptor(es, XXX);
>>>
>>> What must i write as the second parameter XXX ? (processor)
> 
>> You don't need to do that.
> 
> 1) I thought that in order to use a thread pool with io services, i must use
> 
> NioSocketAcceptor acceptor = new
> NioSocketAcceptor(Executors.newCachedThreadPool(), XXX);
> 
> so, i need XXX.
> How can i use a thread pool with io services without that?

It's because the default constructor creates its own thread pool and
launches (the number of cores * 2 + 1) I/O processors automatically.

You don't need to do something special if you want to tune more.

> 2) What is the correct thread pool creation parameters for
> OrderedThreadPoolExecuter?
> corePoolSize =Runtime.getRuntime().availableProcessors() + 1
> maximumPoolSize =Runtime.getRuntime().availableProcessors() + 1
> 
> or should maximumPoolSize be higher than that?

OrderedThreadPoolExecutor and UnorderedThreadPoolExecutor are supposed
to be used with ExecutorFilter.  Therefore, the size of the pool should
depend on your business logic in your IoHandler, which means (the number
of cores * 2 + 1) is not the correct number in this case.  You need to
experiment by yourself to find out the best pool size.  Or you might
want to remove the ExecutorFilter from the filter chain in a certain case.

HTH,
-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/


Mime
View raw message