• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts 1.2 action class

 
Ranch Hand
Posts: 594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In struts 1.2 action classes are singleton ,so each action class is multi threaded for serving many request.So I have to declare declare all parameter inside of execute method or can I declare outside of execute method.If it is declared outside ,when multi threaded it does not make any problem?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 1 action classes are multithreaded, which means you must code them as thread-safe. In a thread-safe object, the only instance variables are those that do not change from one user to the next. All other variables should be local variables within methods.

For example, if you have a Logger class that writes to a log, it would be fine to make this an instance variable since the same instance of this class could safely be used by multiple users. However, if you have a variable called balance representing an individual user's account balance, it would be disastrous to make this an instance variable because one user could place a value in the variable and in the next thread another user could pick up the same value.
 
What's that smell? Hey, sniff this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic