Hello, EJB is NOT supposed to support threading. I am not sure how this is to be enforced. At any rate, I created a session bean that extends Thread. In the run() method, I put a print statement. So when the bean was invoked, the app server did not throw any errors, and it printed out the statement I had placed in the run() method.
Isn't this VERY wrong? Or am I automatically expected to disallow multi-threading?
EJBs are just Java classes, and as such they support threading. It's more like YOU -as the developer- are not supposed to use threading in EJBs, just like you're not supposed to use file I/O. [ April 08, 2007: Message edited by: Ulf Dittmer ]
it printed out the statement I had placed in the run() method.
Is it so, that you did not call run method and still it got executed? When the ejb specs say that EJBs should not use multithreading, it means that one should not spawn new threads inside an EJB's code. This essentially means that a thread(spawned by the bean) should not be executing even after a business method of an EJB returns.
OK, Thanks all, but I have read that one of the functions of the J2EE container is to take care of threading issues. So it still does nothing, and we have to ensure that the bean is not spawning threads, or reading and writing files? What about transaction management?Again, the container is supposed to ensure data integrity for db transactions. So does that mean we have to implement it ourselves? The container actually does nothing?