aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Thread safety of static variables in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Thread safety of static variables in EJB" Watch "Thread safety of static variables in EJB" New topic
Author

Thread safety of static variables in EJB

Bob Runstein
Greenhorn

Joined: May 21, 2002
Posts: 6
I understand that the spec allows final static variables in EJBs. I have seen code that does this in a stateless session bean:
private final static MyHelperClass HELPER = new MyHelperClass();
This is done so that the same instance of the helper class can be used by all of the EJBs of that type.

This looks like it would not be thread safe unless MyHelperClass had no member variables or synchronized access to its member variables.
What are your thoughts on this?
Bob Runstein


Bob Runstein<br />Microsoft Certified Professional<br />Sun Certified Developer for the Java 2 Platform<br />Sun Certified Enterprise Architect for the Java 2 Platform<br /> <br />BR Solutions LLC<br />20797 E. Fair Ln<br />Centennial, CO 80016<br />720-870-7244 home<br />720-254-8966 cell<br />rrunstein@msn.com
 
Consider Paul's rocket mass heater.
 
subject: Thread safety of static variables in EJB