• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InitialContext synchronization

 
Sajid Moinuddin
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using a single initialContext to lookup all the homes. my ejb clients Do something like this.
Context ct = InitialContextFactory.getContext();

ct.lookup("some resource");

Now, My question is, do i have to think about synchronization in the lookup method? Multiple clients are using lookup concurrently. Do I have to be worried about thread safety?

regards,
Sajid
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since, its only a look up. You are safe

You basically Synchronize when..

1) you are writing data, and multiple threads might cause inconsistency.
2) Look up is an Expensive operation...then you might want to synchronize it.Cache the result the first time..and for all subsequent look ups check if its in cache first....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic