Threads in EJB container


EJB programming & troubleshooting: Threads in EJB container

  1. Threads in EJB container (1 messages)

    Hi All

    It's a well known restriction, that you are not allowed to create/use threads in EJBs.
    But what about other objects?
    The all threads usage issue in the J2EE environment is not clear and different people have different opinions about it.

    Can someone please clarify the following issue:
    Can I have a Singleton object that create/use threads living in the EJB Container?, can EJBs call this Singleton?

    Nir Z
  2. Threads in EJB container[ Go to top ]

    Strictly speaking: No, you should not use any thread mechanisms anywhere within the EJB Container. However, practically speaking, there are situations when you just "have to" use it - in which case, people try their luck with their appserver ;-)

    If you're using WLS6.1, I vaguely remember that they have a proprietary "thread pool" implementation whereby you can "lease" a thread, use it & then release it back to the pool. Check out their docs. Similar mechanisms may also be available with other appservers.

    See if that helps.