Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread safety of helpmer methods in ejb

 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I have a small tiff with a college at work regarding thread safety of helper classes .He believes that thread safety is inherent in helper classes since they are called form a thread safe contenxt I believe not....
This is my scenario

I have a stateless session bean calling a helper method to download a file and then unzip it.Is this thread safe
I think not because if two stateless session beans try to access the same webservice at the same time and try tod wonload the file one may over write the other hence I put a time in nano seconds and thread id to distinguish it ..


So if I want to make seomthign thread safe I will need some kind of synchrnoized block in my code (helper) to make it thread safe ....



Also is it a good practise to pass the entitymanger from a sessionbean to a helper class.

Cheers
Priya
 
Rejeev Divakaran
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
calling helper method is thread safe so longer the method is in the same bean class or object which contains the method is instantiated per request or is instance level variable in the bean class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic