You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Trustin Lee <tr...@gmail.com> on 2007/09/02 14:24:09 UTC

Re: ThreadLocal with Mina: ok or not?

Hi Maarten,

You could add a cwiki page about this wonderful discussion! :D

Cheers,
Trustin

On 8/31/07, Maarten Bosteels <mb...@gmail.com> wrote:
> just saw a rather importatnt typo :-)
>
> * usage of Thread locals should NOT last longer than one event
>
> On 8/31/07, Rob Butler <cr...@yahoo.com> wrote:
> >
> > Thanks Maarten.  I was trying to think of an eloquent way to say exactly
> > that when I sent my reply.  I couldn't and then dropped it as
> > 'obvious'.  I'm glad someone was able to state it better.
> >
> > Rob
> >
> > ----- Original Message ----
> > From: Maarten Bosteels <mb...@gmail.com>
> > To: dev@mina.apache.org
> > Sent: Thursday, August 30, 2007 11:21:54 AM
> > Subject: Re: ThreadLocal with Mina: ok or not?
> >
> > On 8/30/07, Chris Winters <ch...@cwinters.com> wrote:
> > >
> > >
> > > >> I'm a Mina newbie, so "the thread pool" he's discussing here is a
> > > little
> > > >> fuzzy, It seems from reading the "Configuring thread model" page
> > > >> (http://mina.apache.org/configuring-thread-model.html) that he's
> > > >> referencing
> > > >> an ExecutorFilter added to the IoFilterChain -- is that correct?
> > >
> > > > Yes.  Everything behind the ExecutorFilter (within the same request)
> > can
> > > > safely use a ThreadLocal.
> > > > Sorry I wasn't more clear.
> >
> >
> >
> > Of course, your code should not assume that two messageReceived events for
> > the same IoSession will be handled by the same thread.
> > So storing something in a threadlocal in the first messageReceived event
> > and
> > trying to retrieve it in the second event is NOT safe.
> > (at least not in combination with an executorfilter)
> > But that's rather obvious, I guess.
> >
> >
> > Great, thanks for the clarification.
> > >
> > > BTW, integrating Mina into my existing networked application has been a
> > > snap. Hope to blog about this soon.
> > >
> > > Best wishes,
> > >
> > > Chris
> > > --
> > > View this message in context:
> > >
> > http://www.nabble.com/ThreadLocal-with-Mina%3A-ok-or-not--tf4354098s16868.html#a12408585
> > > Sent from the Apache MINA Support Forum mailing list archive at
> > Nabble.com
> > > .
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Be a better Heartthrob. Get better relationship answers from someone who
> > knows. Yahoo! Answers - Check it out.
> > http://answers.yahoo.com/dir/?link=list&sid=396545433
> >
>


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