This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Thread Safe - Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Thread Safe - Struts" Watch "Thread Safe - Struts" New topic
Author

Thread Safe - Struts

Akhil Chauhan
Greenhorn

Joined: Jan 06, 2009
Posts: 2
Hi All,

Struts1 Action classes are not thread safe & instantiated only once.
So each request will access the same object.

Small Doubt -
If every request acess the same object.
What about the object inside the action classs, they will b instantiated per request or even they will behave same as Action class.
Ex -
ActionClass
{
List lst = new ArrayList();
}

Here -
ArrayList object wil be instantiated per request ?


Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8713
    
    6

The code you have above has a variable in instance scope. There is one instance of that variable created for each instance of ActionClass, not for each request.
Have a look at the Action Class Design Guidelines

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Akhil Chauhan
Greenhorn

Joined: Jan 06, 2009
Posts: 2
thanks Joe
 
Don't get me started about those stupid light bulbs.
 
subject: Thread Safe - Struts
 
Similar Threads
action class instance
thread safety of helpmer methods in ejb
struts2 modeldriven unable to transfer form data to model object
class variable safe in struts 2 action ?
multithreading in struts...