Themes in Session Beans

I have a session bean that uses a txns managed bean. This bean has one business method that simply delegates to the POJO control that does all the processing. Here, this POJO starts and closes transactions (UserTransaction).

Now the question is whether I can embrace new threads in the POJO so that I can create a new thread when I need to serve 40 or 50 tasks at a time.

I am using EJB2.1 on J2EE 1.4.

Please advice.

Sincerely.

+2


source to share


1 answer


If I understood correctly, there is no need to slice your pojo .

The container has a natural thread. The various requests that are sent to the container have a thread dedicated to them.

Within a dedicated thread, the calling sequence goes from your session bean to your pojo, the threads are still in use. Your pojo is already being called in a multi-threaded way.




Actually, you need to make your Pojo code multithreaded (but not create a thread).

  • Either your pojo instance is multithreaded, that is:

    • no fields
    • ...
  • Otherwise, if your pojo instance is not multithreaded, you only need to create a new Pojo instance for each call and everything will work fine.

+1


source







All Articles