This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes thread safety of helpmer methods in ejb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "thread safety of helpmer methods in ejb" Watch "thread safety of helpmer methods in ejb" New topic

thread safety of helpmer methods in ejb

subu ananthram
Ranch Hand

Joined: May 16, 2004
Posts: 102
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.

Rejeev Divakaran

Joined: Aug 12, 2007
Posts: 27
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.

Regards,<br />Rejeev<br />Blog: <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: thread safety of helpmer methods in ejb