2 Replies Latest reply on Mar 17, 2006 7:04 AM by Hans-Joachim Crawack

    Multithreading&synch. in POJO EJB-Helper classes

    Hans-Joachim Crawack Newbie

      as far as I know in J2EE its "strictly fobidden" to use multithreading or e.g snchronization in EJBs itself. I think the reason is that this disturbs the container, which manage all such tasks by itself.

      But what about POJO EJB-Helper classes, whose methods are used in the EJBs. Is multithreading&synchronisation allowed in such classes???

      Are there other restriction for such POJO classes???

      Thanx in advance

        • 1. Re: Multithreading&synch. in POJO EJB-Helper classes
          Scott Stark Master

          synchronization is synchronization. The restriction is all about are you interferring with the container and its management of the components. You either:

          1. Never use concurrency because its scarry and disallowed by the ejb spec.
          2. Use it and hope for the best.
          3. Use it trying to understand how it can interact with the container and the spec mandated behaviors. At this point your a container developer interacting with a concurrent, transacted system.

          • 2. Re: Multithreading&synch. in POJO EJB-Helper classes
            Hans-Joachim Crawack Newbie

            Hello Scott,
            thanx for the answer!
            Does this mean that also the pojos resp. the ejb-helper classes resp. everything what is deployed on the AS is controlled by the container, ... and not only the ejbs itself? (We use only CMP)

            Background of my question: in our project a scheduled JMX MBean calls periodically a pojo class resp. a method of this class, which then executes a very resource-intensive long lasting job (e.g. with a lot of DB accesses via EJBs). While doing so all other jobs (e.g. DB access to the same tables) are blocked or at least extremely slowed down. We modified the pojo so that the above resource-intensive job is executeted in a single thread with normal priority (just by implementing IF Runnable etc.). The thread can only be started for one time (like a singleton), so its not multithreaded.... now it works and no more blocks take place???