Lawrence Marsh wrote:
>
> Hi
>
> Is the EJBHome object thread safe? I have looked in the spec and
> Monson-Haefels "Enterprise Java Beans" and can find nothing about this in
> either (though I may have missed something of course) I am caching a
> reference to an EJBHome and want to know if I need to add synchronisation
> around the create() method so that it works Ok in a mult-threaded
> environment. I am doing this in a J2EE Client - not in the comntaier itself.

Lawrence,

EJBHomes are not thread-safe.

If you are using them in a multithreaded environment, eg in a servlet you must
synchronize your calls to them (or create a separate EJBHome in each thread).

If you are using them in an EJB there is **normally** no need to worry about
thread safety because it's the app server's responsibility to give you objects
that you don't have to synchronize on.

Note however that this does not apply if you pass EJBHomes around as parameters
or returned values since there is no guarantee that the exact same object won't
be used simultaneously by another EJB. So in this case you will need to
synchronize your calls to EJBHome.



========================================
Ian McCallion
Alexis Systems Limited
Romsey, UK
Tel: +44 1794 514883
Fax: +44 1794 501692
========================================

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to