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.
Scope(ScopeContants.PERTHREAD) public class MyServiceImpl.class implements MyService { private static final Object lock = new Object(); private final Session session; public MyServiceImpl(Session session) { this.session = session; } public void getLogicMethod(String value) { synchronized(lock) { //session do something } } } //Stateless Impl Example public class MyServiceImpl.class implements MyService { private final Session session; public MyServiceImpl(Session session) { this.session = session; } public synchronized void getLogicMethod(String value) { //session do something } } If I were to use the second example, would the getLogicMethod be synchronized across threads while being called from another service? Thanks Guys,