15.4. Thread management

In short, don’t do it. It is the job of the EJB container to ensure that your EJB instance is entered on only one thread at a time, unless the container knows that it is safe to relax this restriction. You should write code as if the EJB were running in a single-threaded environment. The mechanism that the container uses to achieve this illusion of single-threaded operation while maintaining adequate responsiveness is at the discretion of the container vendor. Typically, it will use multiple instances of EJBs with one thread assigned per instance. If there are not enough instances available, then the container will queue method invocations until one becomes available.

Because entity EJB instances and EJB objects are shared ...

Get Applied Enterprise JavaBeans™ Technology now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.