Discussions

EJB design: Entity EJBs and Multi-threading...

  1. Entity EJBs and Multi-threading... (6 messages)

    Hi,
    Is there any sample code to use Multi-threading from an EJB Client and then call the Entity EJB Bean. I need to use my own Multi-threading and would like to know if someone out there has some sample code for the Client and the EJB Bean itself.
    What I am looking for is an example which will allow me to synchronize some methods and allow wait() and notify(). As per the EJB 2.0 Specification, we are not allowed to deal with synchronization through our code.

    Thanks.

    A

    Threaded Messages (6)

  2. Entity EJBs and Multi-threading...[ Go to top ]

    Do note that multithreading is illegal in EJB.

    alex
  3. Entity EJBs and Multi-threading...[ Go to top ]

    Hi,
    I do understand that Multi-threading is not permissible in the EJB Server code as this is handled by the container itself. However, I have read somewhere in the Forums on www.java.sun.com or here itself on www.theserverside.com that the EJB Client could be Multi-threaded and could then talk to the EJB Server.

    Please see the answer by Fengliang Wu at the following link:http://theserverside.com/discussion/thread.jsp?thread_id=825

    If there are any examples I will really appreciate it.

    Thanks.

    A
  4. Entity EJBs and Multi-threading...[ Go to top ]

    Naturally, client can use threads all it wants (as long as the client is not an EJB itself ;-)).

    What are you trying to achieve?
  5. Entity EJBs and Multi-threading...[ Go to top ]

    What if there is scenario where I want a Read thread, a Write thread and a Delete thread. Each thread is synchronized. I am thinking of using a helper class which will extend java.lang.Thread and where all this threading logic will be implemented and all I would need to do is call a simple "read()" method from the Client for example, which will be redirected by the EJB Bean and handed over to the helper class which will not be in the same package as the EJB Bean, Remote Interface or Home Interface. Do you think this sounds correct.

    Thanks.

    A
  6. Entity EJBs and Multi-threading...[ Go to top ]

    I understand that the spec says that we can not use threads in EJBs..but does this mean that we can not make calls on synchronized methods? For example , I've seen somewhere else on this forum a posting about using an RMI object to implement a singleton in which some of the methods were synchronized , does this not violate spec, as you might block on that call? I've implemented this in my own project and it seems to work.
  7. Entity EJBs and Multi-threading...[ Go to top ]

    I understand that the spec says that we can not use threads in EJBs..but does this mean that we can not make calls on synchronized methods? For example , I've seen somewhere else on this forum a posting about using an RMI object to implement a singleton in which some of the methods were synchronized , does this not violate spec, as you might block on that call? I've implemented this in my own project and it seems to work.