On Thu, Nov 14, 2013 at 3:45 PM, Thiago H de Paula Figueiredo < thiag...@gmail.com> wrote:
> When your service has state (injected services doesn't count) which is per > thread. > > Just to clarify, are you saying Injected services wouldn't work in a PerThread Scope? > > On Thu, 14 Nov 2013 18:35:47 -0200, George Christman < > gchrist...@cardaddy.com> wrote: > > Hello I'm looking to build a service where I would be Injecting a >> hibernate session as well as synchronizing a few methods for multi >> threading. I'm >> confused as for when I should be using the PERTHREAD scope. >> > > If your service has state and it (the state) should be the same for more > than one thread (in your case, the lock), it cannot be per thread, > otherwise you'd had one lock per thread, which would be useless in a > multithreaded scenario. > > Also, considering the lock is a static member, it couldn't be shared across threads? > > If I were to use the second example, would the getLogicMethod be >> synchronized across threads while being called from another service? >> > > Yes. That's how Java works. > Thanks Thiago. > > -- > Thiago H. de Paula Figueiredo > Tapestry, Java and Hibernate consultant and developer > http://machina.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York