EJB design: EJBs and Thread management
I know that the EJB specification forbids an EJB from creating or managing threads, but what about blocking? For example, I have a bean that needs to add an item to a shared Queue. The custom add method for the queue is synchronized, so is this okay for the bean to call?
- EJBs and Thread management by prajakt deshpande on January 30 2003 02:31 EST
The answer to your question lies in the question :
Can I use java.util.vector in EJBs . All its methods are synchronized .
J2EE spec does not prohibit from accessing sync. methods. It only prohibits starting , susoending threads from the ejb methods .
hope it helps
thanx and regards
I agree with your bottom line. However, this:
J2EE spec does not prohibit from accessing sync. methods. It only prohibits starting , susoending threads from the ejb methods.
Is not completely true. Except for the rule forbidding EJBs from doing thread management, there is also a rule that sais:
An enterprise Bean must not use thread synchronization primitives to synchronize execution of multiple instances.
This rule is somewhat open for interpretation. For a discussion of this issue see:
yes , synchronizing (ejb) methods is alos not allowed .
I disagree with your interpretation of the spec. The link I posted contains a pretty broad explanation of that, so I won't repeat it here.