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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.