On Nov 23, 2007 3:06 PM, Trustin Lee <[EMAIL PROTECTED]> wrote:
> Hi Frédéric,
>
> On Nov 23, 2007 7:53 AM, Frédéric Brégier <[EMAIL PROTECTED]> wrote:
> > Hi Maarten,
> >
> > Correct me if I am missing something.
> > dispose() seems to release all ressources from the IoService (or 
> > connector), so when you don't need anymore the
> > connector.
> > setWorkerTimeout() was intend to release one thread only inside the pool of 
> > threads after the specified timeout
> > after no use.
> >
> > I read the code, specially from the 6 months ago trunk version and the 
> > current version.
> > It seems that in previous version Mina tries to re-use thread during some 
> > time before returning
> > them definitively to the pool (or to nothing since the default pool was 
> > NewThreadExecutor).
> > In case of NewThreadExecutor, trying to reuse thread instead of created a 
> > new one everyone,
> > I suppose it was the point.
> > Am I correct if I say that, since the underlying pool of thread in the new 
> > trunk
> > is a CachedPool, you don't need anymore this function as you rely on the
> > pool management from CachedPool itself, such that Mina don't have to take 
> > care of this ?
>
> 2.0 still uses NewThreadExecutor for acceptor & connector threads, so
> there's some overhead of spawning a new thread.  This becomes a
> problem when a user tries to request a bunch of connection with bad
> timing because threads will be spawned for each request.  To avoid
> that situation, I programmed AbstractPollingIoConnector's Worker not
> to exit until dispose() is called.  However, this is waste of thread
> if you explicitly specified a thread pool, as you pointed out.
>
> The solution could be not using NewThreadExecutor but using something
> different such as a cached thread pool executor.  However, we are not
> able to share the cached thread pool executor among all acceptors and
> connectors because it means user have to call some global shutdown
> method to shut down the shared thread pool.  Anyways, let me fix the
> problem by replacing NewThreadExecutor with
> Executors.newCachedThreadPool().  :)

Done.  It seems to work fine now.

Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to