users@glassfish.java.net

Re: EJBContext: thread safe?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 19 Aug 2011 11:10:53 -0400

On Fri, Aug 19, 2011 at 11:01 AM, Cheng Fang <cheng.fang_at_oracle.com> wrote:

> Within stateless, stateful, MDB, and Singleton session beans with
> container-managed-concurrency and correctly specified locking metadata,
> don't need to use synchronized. For bean-managed-concurrency Singleton
> bean, yes, you will need to synchronize access to any shared resources,
> including IntialContext. But wouldn't it be easier and cheaper to just use
> a new InitialContext?
>

I'm probably working with outdated information, but the act of creating a
new InitialContext() used to be regarded as really heavyweight. You would
do it when you had to, but you would cache it (and thereby of course
introduce thread safety concerns) whenever you could. Am I hearing you
right that InitialContext creation is now cheap?

Best,
Laird

-- 
http://about.me/lairdnelson