Stateless Beans : Each thread / request will receive a separate EJB instance from the pool. SLB should not contain any user session data, any state. The same code can be executed in parallel. One instance is available one thread at a time.
Statefull beans are synchronized for a user session. Each user will receive their own instance of the sessions. The second thread / request will wait for the end of the first thread. Statefull EJB can store user data. One user cannot execute the same code in parallel. Different users can execute the same code in parallel.
If you are accessing a resource that does not allow concurrent access, use Singleton EJB . As the name suggests, there is only one instance. By default, access to EJB Singleton is possible from only one stream (parallelism of the managed container and @Lock (WRITE)).
Peter Šály
source share